Skip to content

Fix App Management API app-not-found error message (shop/issues-develop#226)#7403

Merged
isaacroldan merged 1 commit into
mainfrom
04-27-fix_app_management_app_not_found_error
Apr 28, 2026
Merged

Fix App Management API app-not-found error message (shop/issues-develop#226)#7403
isaacroldan merged 1 commit into
mainfrom
04-27-fix_app_management_app_not_found_error

Conversation

@isaacroldan

@isaacroldan isaacroldan commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

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 a TypeError: 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 GraphQL appByKey query returns null (HTTP 200) when the client ID does not exist, but AppManagementClient.appFromIdentifiers was destructuring the result unconditionally.

WHAT is this pull request doing?

  • packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts: return undefined when appByKey resolves to null, mirroring PartnersClient. The caller in services/context.ts then renders the existing abort error.
  • Added two unit tests covering the null-app and happy-path branches of appFromIdentifiers.
  • Patch changeset for @shopify/app.

How to test your changes?

  1. Check out this branch and pnpm build it.
  2. From any app directory, run:
    shopify app config link --client-id=does-not-exist
    
    against a Dev Dashboard organization (App Management).
  3. Expect a clean "No app with client ID …" abort message — no stack trace.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

…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.
Copilot AI review requested due to automatic review settings April 27, 2026 13:19
@isaacroldan isaacroldan requested review from a team as code owners April 27, 2026 13:19

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 undefined from AppManagementClient.appFromIdentifiers when the API returns app: 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 amcaplan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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                        │
│                                                                                │
╰────────────────────────────────────────────────────────────────────────────────╯


Copy link
Copy Markdown
Contributor Author

This is an old issue, seems like this is currently throwing and being cached somewhere else.
But the fix still makes sense, app could be undefined, so we shouldn't try to do app.activeRelease without checking. Is safer to return undefined here

@isaacroldan isaacroldan added this pull request to the merge queue Apr 28, 2026
Merged via the queue into main with commit a15d268 Apr 28, 2026
31 checks passed
@isaacroldan isaacroldan deleted the 04-27-fix_app_management_app_not_found_error branch April 28, 2026 10:45
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.

4 participants