Skip to content
Draft
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 @@ -109,6 +109,23 @@ describe('createExtensionSpecification', () => {
// Then
expect(got.clientSteps).toEqual(testClientSteps)
})

test('does not let explicit-undefined spec keys shadow the computed defaults', () => {
// When — wrapper-helper style: optional fields are forwarded as `undefined`
const got = createExtensionSpecification({
identifier: 'test_extension',
appModuleFeatures: () => [],
experience: undefined,
uidStrategy: undefined,
buildConfig: undefined,
clientSteps: undefined,
})

// Then — defaults apply instead of `undefined` leaking through
expect(got.experience).toBe('extension')
expect(got.uidStrategy).toBe('uuid')
expect(got.buildConfig).toEqual({mode: 'none'})
})
})

describe('createConfigExtensionSpecification', () => {
Expand Down
9 changes: 7 additions & 2 deletions packages/app/src/cli/models/extensions/specification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {ApplicationURLs} from '../../services/dev/urls.js'
import {Result} from '@shopify/cli-kit/node/result'
import {capitalize} from '@shopify/cli-kit/common/string'
import {ParseConfigurationResult, zod} from '@shopify/cli-kit/node/schema'
import {getPathValue, setPathValue} from '@shopify/cli-kit/common/object'
import {getPathValue, pickBy, setPathValue} from '@shopify/cli-kit/common/object'
import {JsonMapType} from '@shopify/cli-kit/node/toml'

export type ExtensionFeature =
Expand Down Expand Up @@ -222,7 +222,12 @@ export function createExtensionSpecification<TConfiguration extends BaseConfigTy
clientSteps: spec.clientSteps,
buildConfig: spec.buildConfig ?? {mode: 'none'},
}
const merged = {...defaults, ...spec}
// Strip undefined keys from `spec` before merging so wrapper helpers that
// forward optional fields as explicit `undefined` don't shadow the defaults.
const definedSpec = pickBy(spec as unknown as Record<string, unknown>, (value) => value !== undefined) as Partial<
CreateExtensionSpecType<TConfiguration>
>
const merged = {...defaults, ...definedSpec} as typeof defaults & CreateExtensionSpecType<TConfiguration>

return {
...merged,
Expand Down
Loading