Skip to content

Fall back to local validation when a remote contract cannot be compiled - #8477

Closed
alfonso-noriega wants to merge 1 commit into
mainfrom
remote-spec-schema-resilience
Closed

Fall back to local validation when a remote contract cannot be compiled#8477
alfonso-noriega wants to merge 1 commit into
mainfrom
remote-spec-schema-resilience

Conversation

@alfonso-noriega

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

A server-provided module validation schema that AJV cannot compile crashes every shopify app * command at load time — including for apps that don't use the affected module at all. createConfigExtensionInstances parses the app config against every remote app-config spec, so one bad contract takes down the whole CLI for that environment.

Live repro: any app command against a shop/world local rig whose custom-data spec renders "enum": [] for standard metaobject templates (empty taxonomy registry — empty enum is invalid JSON Schema):

schema is invalid: data/definitions/MetaobjectNamespaces/properties/standard_metaobjects/items/enum
must NOT have fewer than 1 items, …
    at map
    at createConfigExtensionInstances

The server-side instance of that bug is fixed in shop/world#1016890, but the CLI shouldn't hard-fail on data it doesn't control: a malformed contract for one module should degrade, not brick app info.

WHAT is this pull request doing?

unifiedConfigurationParserFactory now degrades per module when a contract is unusable:

  • Normalisation failure (broken $ref): fall back to the merged spec's local zod parser for that module
  • Compilation failure (first jsonSchemaValidate call, e.g. empty enum): return the zod parse result for that call
  • Either way: outputWarn once per module identifier per process, naming the module and the underlying reason — and noting the server still validates on deploy, so nothing ships unvalidated

How to test your changes?

  • pnpm vitest run packages/app/src/cli/utilities/json-schema.test.ts — 3 new tests: empty-enum contract → zod result + single warning (deduped on repeat calls); zod errors still gate when the contract is broken; broken $ref → factory returns the local parser
  • Manual: point the CLI at a rig serving the invalid custom-data contract — shopify app info loads with a warning instead of crashing

Measuring impact

  • n/a — resilience fix; the warning line is the observable change

A server-provided validation schema that fails normalisation (broken
$ref) or AJV compilation (e.g. an empty enum, which some environments
render when the data backing it is empty) crashed every app command at
load time, inside createConfigExtensionInstances - including for apps
that do not use the affected module at all.

unifiedConfigurationParserFactory now degrades per module: an unusable
contract logs a once-per-process warning naming the module and reason,
and parsing falls back to the CLI's local zod schema. The server still
validates on deploy, so nothing ships unvalidated.

Repro: any app command against a shop/world rig whose custom-data spec
renders "enum": [] for standard metaobject templates (empty taxonomy
registry). Server-side fix for that instance: shop/world#1016890.

Assisted-By: pi
Assisted-By: devx/3210d700-6e94-4dca-95ca-6372c5535f56
@alfonso-noriega
alfonso-noriega requested a review from a team as a code owner September 4, 2026 14:15
@github-actions github-actions Bot added the Area: @shopify/app @shopify/app package issues label Sep 4, 2026
@alfonso-noriega

Copy link
Copy Markdown
Contributor Author

Closing — the triggering issue is rig-local; withdrawing for now.

@alfonso-noriega
alfonso-noriega deleted the remote-spec-schema-resilience branch September 4, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/app @shopify/app package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant