fix(credentials): resolve canonical from --name when omitted → fixes 405 (CLI-123)#455
Open
fhacloid wants to merge 1 commit into
Conversation
…mitted (CLI-123)
`credential update` was sending PUT to the collection endpoint
/organizations/{org}/credentials when --canonical was not provided,
because an empty canonical string caused the route to degenerate.
The API returns 405 on PUT to the collection.
Option B: when --canonical is omitted, list the org's credentials and
match by --name / --path, mirroring the create --update lookup. If no
match is found, a clear error is returned instead of a silent 405.
Explicit --canonical still wins when provided.
Adds an offline regression test that asserts PUT targets the item route
/organizations/{org}/credentials/{canonical}, not the collection.
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 CLI-123 —
cy credential updatewith--nameonly (no--canonical) was 405-ing on all invocations.Root cause:
update.gonever marked--canonicalas required (unlikecreate.go). When omitted,canonical=""caused the route to degenerate from/organizations/{org}/credentials/{canonical}to the collection endpoint/organizations/{org}/credentials. The API returns 405 on PUT to the collection (only GET+POST are allowed there). Present since the command was introduced (a465971, 2024-03-05).Customer context (Alchemy / Nicolas Maillat, support-alchemy):
Fix — Option B (name-based canonical auto-resolve):
When
--canonicalis omitted,updatenow lists the org's credentials and resolves the canonical by matching--name/--path, mirroring thecreate --updatelookup. The resolved canonical is then used to PUT the item endpoint. Explicit--canonicalstill wins when provided. A clear error is returned if no match is found.Note on overwrite semantics: PUT replaces the entire
rawblob — there is no partial field-merge on the API. Customers must pass ALL fields to avoid data loss. This is a separate concern; the API would need a new endpoint for partial update.Test plan
TestUpdateByNameResolvesCanonical_ItemRoute— offline regression test: asserts PUT goes to/organizations/{org}/credentials/{canonical}(item route), not the collection. Failed before this fix.TestDefaultCredentialPath,TestFindCredentialForUpdate)go build ./...cleancy --org <org> credential update custom --name <name> --field k=vshould no longer 405🤖 Generated with Claude Code