fix(secret): aws secret manager fails when the secret name contains a slash#13519
Merged
nic-6443 merged 2 commits intoJun 12, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes AWS Secrets Manager lookups when secret names contain / by changing APISIX’s $secret://aws/... resolution to try the longest possible secret name first and progressively shift trailing path segments into the JSON field portion only on ResourceNotFoundException. It also adds regression tests, updates documentation to describe the precedence rule, and seeds additional test secrets into the CI localstack environment.
Changes:
- Update
apisix/secret/aws.luato implement longest-name-first fallback splitting (right-to-left) on NotFound. - Add tests covering slash-containing secret names, “full key is the secret name” behavior, and end-to-end
$secret://aws/...resolution. - Document the new precedence rule in EN/ZH terminology docs and seed corresponding secrets in CI localstack.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
apisix/secret/aws.lua |
Implements fallback lookup logic for slash-containing secret names by shifting segments from right to field name on NotFound. |
t/secret/aws.t |
Adds regression tests for slash-named secrets, full-path secret names, and $secret:// URI resolution. |
ci/init-common-test-service.sh |
Seeds new localstack secrets used by the new tests. |
docs/en/latest/terminology/secret.md |
Documents the new AWS slash-name precedence/lookup behavior. |
docs/zh/latest/terminology/secret.md |
Same documentation update in Chinese. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…NotFoundException)
membphis
approved these changes
Jun 12, 2026
AlinsRan
approved these changes
Jun 12, 2026
shreemaan-abhishek
approved these changes
Jun 12, 2026
shreemaan-abhishek
approved these changes
Jun 12, 2026
wistefan
pushed a commit
to wistefan/apisix
that referenced
this pull request
Jun 16, 2026
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.
Description
AWS Secrets Manager allows slashes in secret names, but
apisix/secret/aws.luasplits the key at the first slash. For$secret://aws/1/john/secret/john-key-authwhere the secret is actually namedjohn/secret, APISIX sendsSecretId=johnand treatssecret/john-key-authas the JSON field name, so the lookup fails withResourceNotFoundException(vault.lua, by contrast, splits at the last slash).The reference URI is inherently ambiguous — there is no way to know upfront where the secret name ends and the JSON field begins. This PR resolves it with a longest-name-first fallback: first try the whole remaining key as the
SecretIdwith no field, and onResourceNotFoundExceptionprogressively move path segments from the right into the field position, e.g. forjohn/secret/john-key-auth:SecretId=john/secret/john-key-auth(no field)SecretId=john/secret, fieldjohn-key-authSecretId=john, fieldsecret/john-key-authThe first successful lookup wins. A definitive non-NotFound error (e.g. auth failure, connection error) aborts immediately instead of trying more splits. Keys without slashes behave exactly as before, and since
apisix/secret.luacaches resolved values by URI in an lrucache, the extra requests only happen on cache miss.Precedence note: the old behavior always split at the first slash. If both interpretations exist (a secret literally named
johncontaining the fieldsecret/john-key-authand a secret namedjohn/secret), the longest matching secret name now takes precedence. This rule is documented in the secret terminology doc (en + zh).#11655 attempted to fix this earlier but went stale; this PR picks the issue up with the fallback-resolution approach and adds regression tests (slash-named secret with field lookup, full key as secret name, end-to-end
$secret://URI resolution), with the corresponding secrets seeded into the localstack used by CI.Which issue(s) this PR fixes:
Fixes #11647
Checklist