Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type FetchSpecificationsQuery = {
identifier: string
externalIdentifier: string
features: string[]
clientSteps?: string | null
uidStrategy:
| {appModuleLimit: number; isClientProvided: boolean}
| {appModuleLimit: number; isClientProvided: boolean}
Expand Down Expand Up @@ -55,6 +56,7 @@ export const FetchSpecifications = {
{kind: 'Field', name: {kind: 'Name', value: 'identifier'}},
{kind: 'Field', name: {kind: 'Name', value: 'externalIdentifier'}},
{kind: 'Field', name: {kind: 'Name', value: 'features'}},
{kind: 'Field', name: {kind: 'Name', value: 'clientSteps'}},
{
kind: 'Field',
name: {kind: 'Name', value: 'uidStrategy'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ query fetchSpecifications($organizationId: ID!) {
identifier
externalIdentifier
features
clientSteps
uidStrategy {
appModuleLimit
isClientProvided
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {ClientSteps} from '../../services/build/client-steps.js'
import {gql} from 'graphql-request'

export const ExtensionSpecificationsQuery = gql`
Expand Down Expand Up @@ -36,6 +37,7 @@ export interface RemoteSpecification {
gated: boolean
externalIdentifier: string
experience: 'extension' | 'configuration' | 'deprecated'
clientSteps?: ClientSteps
options: {
managementExperience: 'cli' | 'custom' | 'dashboard'
registrationLimit: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ import {
AppLogsSubscribeMutationVariables,
} from '../../api/graphql/app-management/generated/app-logs-subscribe.js'
import {SourceExtension} from '../../api/graphql/app-management/generated/types.js'
import {ClientSteps} from '../../services/build/client-steps.js'
import {getPartnersToken} from '@shopify/cli-kit/node/environment'
import {ensureAuthenticatedAppManagementAndBusinessPlatform, Session} from '@shopify/cli-kit/node/session'
import {isUnitTest} from '@shopify/cli-kit/node/context/local'
Expand Down Expand Up @@ -456,6 +457,7 @@ export class AppManagementClient implements DeveloperPlatformClient {
identifier: spec.identifier,
externalIdentifier: spec.externalIdentifier,
gated: false,
clientSteps: parseClientSteps(spec.clientSteps),
options: {
managementExperience: 'cli',
registrationLimit: spec.uidStrategy.appModuleLimit,
Expand Down Expand Up @@ -1426,3 +1428,7 @@ function toUserError(err: CreateAppVersionMutation['appVersionCreate']['userErro
function isStoreProvisionable(permissions: string[]) {
return permissions.includes('ondemand_access_to_stores')
}
function parseClientSteps(clientSteps: string | null | undefined): ClientSteps | undefined {
if (!clientSteps) return undefined
return JSON.parse(clientSteps)
}

Choose a reason for hiding this comment

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

Unhandled JSON.parse can crash specifications fetch

clientSteps is sourced from a remote API field (spec.clientSteps) and is parsed with JSON.parse without a try/catch. If the API returns invalid JSON (e.g., empty string, partially-written JSON, a plain string, or an unexpectedly formatted value), JSON.parse will throw and the entire specifications() call will reject.

Evidence:

function parseClientSteps(clientSteps: string | null | undefined): ClientSteps | undefined {
  if (!clientSteps) return undefined
  return JSON.parse(clientSteps)
}

This can make the CLI fail to fetch extension specifications, potentially breaking deploy/build flows for users receiving malformed clientSteps (or during a transient backend bug).

Loading