Fix App Management API app-not-found error message (shop/issues-develop#226)#7403
Conversation
…op#226) When `shopify app config link --client-id=<id>` is invoked against a Dev Dashboard app, `AppManagementClient.appFromIdentifiers` would unconditionally destructure `app.activeRelease.version`, throwing a TypeError when the GraphQL `appByKey` query returned `null` for a non-existent client ID. Return undefined in that case so the caller in `appFromIdentifiers` (services/context.ts) can render the friendly "No app with client ID ... found" abort error, matching PartnersClient behaviour.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR prevents a null-dereference when resolving an app by client ID through the App Management API, enabling upstream code to surface the intended “app not found” friendly error instead of a stack trace.
Changes:
- Return
undefinedfromAppManagementClient.appFromIdentifierswhen the API returnsapp: null. - Add unit tests covering both “not found” and “found” cases for
appFromIdentifiers. - Add a changeset to ship the user-facing fix as a patch.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts | Adds a guard for app: null to avoid crashing and allow upstream friendly messaging. |
| packages/app/src/cli/utilities/developer-platform-client/app-management-client.test.ts | Adds coverage ensuring appFromIdentifiers returns undefined on missing app and returns the mapped app when present. |
| .changeset/handle-app-management-app-not-found.md | Declares a patch release note for the improved “client ID not found” experience. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
amcaplan
left a comment
There was a problem hiding this comment.
I'm not seeing the originally complained about behavior...
in cli/ on main
› SHOPIFY_CLI_NEVER_USE_PARTNERS_API=1 pnpm -s shopify:run app config link --path ~/dev/experiments/lean-supply-app --client-id abcdefg
╭─ error ────────────────────────────────────────────────────────────────────────╮
│ │
│ No app with client ID `abcdefg` found │
│ │
│ Next steps: │
│ • Check that your account has permission to develop apps for this │
│ organization or contact the owner of the organization to grant you │
│ permission │
│ • Run `shopify auth login` to log into a different account than │
│ ariel.caplan@shopify.com │
│ • Pass `--reset` to your command to create a new app │
│ │
╰────────────────────────────────────────────────────────────────────────────────╯
|
This is an old issue, seems like this is currently throwing and being cached somewhere else. |

WHY are these changes introduced?
Fixes shop/issues-develop#226
When
shopify app config link --client-id=<unknown>is run against a Dev Dashboard (App Management) app, the CLI crashed with aTypeError: Cannot read properties of null (reading 'activeRelease')stack trace, instead of the friendly "No app with client ID … found" abort that Partners apps already surface. The underlying GraphQLappByKeyquery returnsnull(HTTP 200) when the client ID does not exist, butAppManagementClient.appFromIdentifierswas destructuring the result unconditionally.WHAT is this pull request doing?
packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts: returnundefinedwhenappByKeyresolves tonull, mirroringPartnersClient. The caller inservices/context.tsthen renders the existing abort error.appFromIdentifiers.@shopify/app.How to test your changes?
pnpm buildit.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add