Skip to content

Commit

Permalink
Merge pull request #5082 from Shopify/shauns/12-11-fix_exception_rais…
Browse files Browse the repository at this point in the history
…ed_when_selectorcreateapp_fails_to_find_an_app

Fix exception raised when selectOrCreateApp fails to find an app
  • Loading branch information
shauns authored Dec 13, 2024
2 parents e817956 + dea9a09 commit d8c8998
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/app/src/cli/services/dev/select-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
}
}

0 comments on commit d8c8998

Please sign in to comment.