fix(server): five audit_log calls omit the required action argument - #3181
Merged
Conversation
audit_log(event_type, action, **kwargs) takes action positionally, but five call sites pass event_type as a keyword and never pass action, so each raises TypeError: missing a required argument: 'action'. In routes/approvals.py the four calls are unguarded and run after the approval has already been committed, so the endpoint 500s on a request that actually succeeded and no audit record is written. In services/cloud/credential_resolver.py the call sits inside a try/except that logs at debug level, so credential-use auditing silently never records anything. Pass action positionally in the same style as routes/auth.py.
Owner
|
thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
audit_logtakesactionas a required positional parameter:Five call sites pass
event_typeas a keyword and never passactionat all, so eachraises:
server/routes/approvals.pyserver/services/cloud/credential_resolver.pyImpact differs by site
routes/approvals.py— unguarded, fires after the state change. At L421 the approvalhas already been committed and the job already unblocked in the queue before the audit
call runs:
So the endpoint returns 500 for an approval that actually succeeded, and no audit record
is written. Same for reject (L486) and the bulk paths (L572, L636).
credential_resolver.py— swallowed. That call sits inside atry/except Exceptionthat logs at debug level, so credential-use auditing has silently never recorded anything.
The correct shape is already in the codebase
routes/auth.pycalls it correctly throughout — positionalevent_type, then ahuman-readable
actionstring:approvals.pyis the only module that consistently disagrees.Verification
Binding each call against the real signature, with a working
auth.pycall as control:Change
Passes
actionpositionally at all five sites, matchingauth.py's phrasing. Every valueinterpolated (
request.job_id,user.username,provider,credential_name) is alreadyin scope and already used in the adjacent
detailsdict. No behaviour changes beyond theaudit records now actually being written.
🤖 Generated with Claude Code