fix(platform): apply commands fail to create new resources#208
Merged
Conversation
IsNotFound checked only the ErrNotFound sentinel; SDK Resolve* methods
return *APIResponseError{404} on empty search results, which never
matched. blueprints apply always errored on new names. device-groups
apply had the inverse problem — no IsNotFound check at all, so any
error (including 500s) fell through to create.
Fix: extend IsNotFound to also match *APIResponseError with status 404.
Add the missing guard to device-groups apply to match the blueprint
pattern. Fixes #207.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
platform.IsNotFoundmatched only theErrNotFoundsentinel viaerrors.Is; SDKResolve*methods return*APIResponseError{404}on empty search results, which never matchedblueprints applyalways errored on new names — resolver returned 404,IsNotFoundreturned false, command exited instead of creatingplatform-device-groups applyhad the inverse problem: noIsNotFoundguard at all, so any error (500s, auth failures) fell through to a create attemptFix
platform.IsNotFoundnow also matches*APIResponseErrorwith status 404 (viajamfplatform.AsAPIError)IsNotFoundguard toplatform-device-groups applyto match the blueprint patternTestIsNotFoundto cover SDK 404, wrapped SDK 404, SDK 500 (must not match), sentinel, nilTest
Live-tested on
platform-nmartinfor both commands:GET(empty) →POST→ 201 ✓GET(found) →PATCH/PUT→ 204/200 ✓Closes #207
🤖 Generated with Claude Code