diff --git a/packages/app/src/cli/services/dev/select-app.ts b/packages/app/src/cli/services/dev/select-app.ts index 72f3b81b54..548be40fe7 100644 --- a/packages/app/src/cli/services/dev/select-app.ts +++ b/packages/app/src/cli/services/dev/select-app.ts @@ -4,6 +4,7 @@ import {Organization, MinimalOrganizationApp, OrganizationApp} from '../../model import {getCachedCommandInfo, setCachedCommandTomlPreference} from '../local-storage.js' import {DeveloperPlatformClient} from '../../utilities/developer-platform-client.js' import {AppConfigurationFileName} from '../../models/app/loader.js' +import {BugError} from '@shopify/cli-kit/node/error' /** * Select an app from env, list or create a new one: @@ -45,7 +46,14 @@ export async function selectOrCreateApp( if (selectedToml) setCachedCommandTomlPreference(selectedToml) const fullSelectedApp = await developerPlatformClient.appFromId(app) - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return fullSelectedApp! + + if (!fullSelectedApp) { + // This is unlikely, and a bug. But we still want a nice user facing message plus appropriate context logged. + throw new BugError( + `Unable to fetch app ${app.apiKey} from Shopify`, + 'Try running `shopify app config link` to connect to an app you have access to.', + ) + } + return fullSelectedApp } }