Repository navigation
feat(addons): log the reason behind a generic denial - #12875
Merged
Merged
Conversation
The dispatch and sibling addon routes answer 403 "Addon request denied" for every error that is not a named type, and the server logged only the status code. An operator could not tell which check refused a request. Write one Warn line at each fall-through to the generic denial: the action (or route pattern), the add-on ID, the typed error kind and the innermost message of the error chain. Fixed refusals (the recovery and update action rule, an invalid add-on ID, digest or path) log the rule name. The request body, arguments, headers, cookies and credential references are never logged. The response is unchanged. Assisted-by: Claude:claude-sonnet-5-5 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
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.
What
The addon routes answer
403 "Addon request denied"for every error that is not a named type. The server logged only the status code, so an operator could not tell which check refused a request.This adds one Warn line at each place that returns the generic denial:
resultErrorfall-through (used by dispatch, relay and the other addon routes): logs the action (or the route pattern when the request has no parsed action), the add-on ID, the error kind (ErrForbidden,ErrUnavailable, or the Go type) and the innermost message of theerrors.Unwrapchain.What is not logged
The request body, arguments, API key, session cookie, Authorization header and credential references. Only the
actionandaddonIdof an already parsed request are used.Response
Unchanged: same status, same generic message, same JSON shape.
Tests
A new spec in
installrefusal_test.gochecks that the response body is exactly the generic JSON, that one log line is written with the action, add-on ID, kind and reason, that the fixed-rule path logs the rule, and that the token,Bearerand the request arguments are absent from the log.go vet -tags auth ./core/http/endpoints/addons/is clean.CGO_ENABLED=1 go test -tags auth ./core/http/endpoints/addons/: 111 of 111 specs passed, 0 failed. No spec needs Docker or Postgres.Not run
The full repository build and the other packages' tests. Documentation is not changed because no user-facing behavior or API changes.