fix(sip): resolve short realm names through realm list - #49
Open
jzeng-bw wants to merge 1 commit into
Open
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
Fixes #37.
What was wrong
The SIP commands advertised realm references as an ID, short name, or FQDN, but
Service.GetRealmpassed the reference directly toGET /accounts/{accountId}/realms/{ref}. On the account reported in #37,--realm vapireturned 404 while the same realm's ID and FQDN worked. This broke the documented credential workflow and also affected realm reads and writes that use the shared resolver.Existing credential-create mocks returned success for
/realms/vapi, so they did not reproduce the production failure.The fix
GetRealmkeeps the direct lookup first. If it returns 404 for a valid, non-numeric short name, it now:GET /accounts/{accountId}/realms.For example,
band sip credential list --realm vapi --plainnow resolves through/realms/vapi→/realms→/realms/{id}, then lists credentials under that ID. The fallback adds two GETs only when the initial short-name lookup returns 404; successful direct lookups remain a single GET.The shared change covers realm get/update/delete and all credential
--realmconsumers.UpdateRealmadditionally uses the resolved ID for its PUT and any follow-up GET; otherwise its initial read would succeed but the write would still target the unsupported short name. Its existing read-modify-write behavior continues to preserve omitted fields.Compatibility and error behavior
Tests
TestGetRealmResolution— 13 cases covering short names, mixed case, hyphenated names, direct ID/FQDN/name success, missing names/IDs/FQDNs, initial 401/403/500, list 403, and ambiguous matches. Asserts the request paths and order, exit codes, and returned realm details./realms/vapiand serves list/ID endpoints, so existing idempotency and secret-handling tests exercise the fallback.TestUpdateRealm_ReadModifyWritePreservesUnspecifiedFieldsnow rejects short-name requests and requires the canonical ID on the detail and update paths while checking preservation of description/default fields.Verified locally with Go 1.26.6:
go test ./internal/sip ./cmd/sip ./cmd; formatting andgit diff --checkclean. CI builds and full tests pass on Ubuntu, macOS, and Windows; lint, govulncheck, and Snyk checks also pass. Live API verification was not performed.This PR was substantially AI-generated with Codex.