Skip to content

Fix uid placement for single-entry [[extensions]] TOMLs#7479

Open
nickwesselman wants to merge 2 commits intomainfrom
fix-uid-placement-single-extension-array
Open

Fix uid placement for single-entry [[extensions]] TOMLs#7479
nickwesselman wants to merge 2 commits intomainfrom
fix-uid-placement-single-extension-array

Conversation

@nickwesselman
Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

addUidToToml branched on extensionsArray.length > 1 to decide between regex-based positional insertion (inside the matching [[extensions]] block) and a top-level WASM patch. A single-entry [[extensions]] array fell into the top-level branch, so uid was written outside the [[extensions]] block — the wrong location.

This is the shape produced by current shopify app init templates (e.g. ui_extension app-home), so every newly-init'd app from those templates ended up with a top-level uid after the first linkedAppContext run.

Requested by Nick Wesselman nick.wesselman@shopify.com. Investigated and authored by River.

WHAT is this pull request doing?

  • Branches on whether extensionsArray exists at all. Any array shape (length 1 or many) gets the regex insertion path.
  • Legacy single-extension TOMLs with top-level type/handle fields still get the top-level file.patch path.
  • Adds a regression test using the exact app init template TOML shape (single-entry [[extensions]] array).
  • Adds a @shopify/app patch changeset.

How to test your changes?

  1. shopify app init (using a template that produces a single [[extensions]] entry, e.g. ui_extension app-home).
  2. Run any flow that triggers linkedAppContext (e.g. shopify app dev).
  3. Confirm uid is written inside the [[extensions]] block, after handle, rather than at the top level of the TOML.

Or run the focused unit tests:

pnpm vitest run packages/app/src/cli/services/app/add-uid-to-extension-toml.test.ts

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

addUidToToml branched on `extensionsArray.length > 1` to decide between
the regex-based positional insertion (inside the matching [[extensions]]
block) and a top-level WASM patch. A single-entry [[extensions]] array
fell into the top-level branch, so `uid` was written outside the
[[extensions]] block — the wrong location.

This is the shape produced by current `shopify app init` templates
(e.g. ui_extension app-home), so every newly-init'd app from those
templates ended up with a top-level `uid` after the first
`linkedAppContext` run.

Fix: branch on whether `extensionsArray` exists at all. Any array shape
(length 1 or many) gets the regex insertion path. Legacy single-extension
TOMLs with top-level `type`/`handle` fields still get the top-level
`file.patch` path.

Adds a regression test using the exact app init template TOML shape.

Co-authored-by: Nick Wesselman <nick.wesselman@shopify.com>
@nickwesselman
Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions github-actions Bot added the Area: @shopify/app @shopify/app package issues label May 6, 2026
@nickwesselman nickwesselman marked this pull request as ready for review May 6, 2026 17:18
@nickwesselman nickwesselman requested review from a team as code owners May 6, 2026 17:18
@nickwesselman
Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🫰✨ Thanks @nickwesselman! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260506171759

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🫰✨ Thanks @nickwesselman! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260506171941

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

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.

2 participants