Skip to content

fix(platform): apply commands fail to create new resources#208

Merged
neilmartin83 merged 1 commit into
mainfrom
fix/blueprint-device-group-apply-not-found
May 14, 2026
Merged

fix(platform): apply commands fail to create new resources#208
neilmartin83 merged 1 commit into
mainfrom
fix/blueprint-device-group-apply-not-found

Conversation

@neilmartin83
Copy link
Copy Markdown
Member

Summary

  • platform.IsNotFound matched only the ErrNotFound sentinel via errors.Is; SDK Resolve* methods return *APIResponseError{404} on empty search results, which never matched
  • blueprints apply always errored on new names — resolver returned 404, IsNotFound returned false, command exited instead of creating
  • platform-device-groups apply had the inverse problem: no IsNotFound guard at all, so any error (500s, auth failures) fell through to a create attempt

Fix

  • platform.IsNotFound now also matches *APIResponseError with status 404 (via jamfplatform.AsAPIError)
  • Added the missing IsNotFound guard to platform-device-groups apply to match the blueprint pattern
  • Extended TestIsNotFound to cover SDK 404, wrapped SDK 404, SDK 500 (must not match), sentinel, nil

Test

Live-tested on platform-nmartin for both commands:

  • New name → GET (empty) → POST → 201 ✓
  • Existing name → GET (found) → PATCH/PUT → 204/200 ✓

Closes #207

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown
Collaborator

@ktn-jamf ktn-jamf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@neilmartin83 neilmartin83 merged commit 8a2ee28 into main May 14, 2026
1 check passed
@neilmartin83 neilmartin83 deleted the fix/blueprint-device-group-apply-not-found branch May 14, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

blueprints apply fails to create new blueprints — errors on empty search result instead of creating

2 participants