Conversation
CheckACLs reads the API key's own ACLs via GET /1/keys/{key} to
compare against what the command declares it needs. That endpoint
requires the `search` ACL, which is unrelated to most commands, so a
key that's missing it (or otherwise can't self-read) gets a bare
error from the preflight and the command never runs, even when the
key holds every ACL it actually needs.
Make the self-read failure non-fatal, the same way the admin-key
check above it already treats a failing ListApiKeys as "not admin"
rather than an error. The real API call remains the authority on
whether the key is sufficient.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
TIP This summary will be updated as you push new changes.
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.
Summary
Fixes #183.
CheckACLsruns as a preflight before every command. For a non-admin key it reads the key's own ACLs viaGET /1/keys/{key}to compare against what the command declares it needs (pkg/auth/auth_check.go:122-129).That self-read requires the
searchACL — unrelated to whatever ACL the command actually needs. If the key lackssearch(or otherwise can't self-read), the preflight returns a bare 403 and the command never runs, even when the key holds exactly the ACLs it needs. The friendlyerrMissingACLsremediation message is never reached, since it depends on the self-read having succeeded first.Fix
Treat a failing self-read as non-fatal — the same way the admin-key branch just above it already treats a failing
ListApiKeysas "not admin" rather than an error. The real API call the command makes remains the authority on whether the key is actually sufficient.Test plan
Test_CheckACLsinpkg/auth/auth_check_test.go: self-read failure + non-admin ACL need (should succeed), self-read failure + admin ACL need (should still returnerrAdminAPIKeyRequired)mainand passes with the fixgo build ./...,go vet ./...cleango test ./pkg/auth/...passes, no regressions elsewhere🤖 Generated with Claude Code