Skip to content

Fix storeByDomain connecting to the wrong store on substring domain match#8043

Open
isaacroldan wants to merge 2 commits into
mainfrom
store-by-domain-exact-match
Open

Fix storeByDomain connecting to the wrong store on substring domain match#8043
isaacroldan wants to merge 2 commits into
mainfrom
store-by-domain-exact-match

Conversation

@isaacroldan

@isaacroldan isaacroldan commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Why

AppManagementClient.storeByDomain used accessibleShops(search:) and returned the first fuzzy result. When one store domain is a substring of another, the CLI could connect to the wrong dev store and then cache that store in dev_store_url.

What

  • Normalize the requested domain and return only the store whose shopDomain matches exactly.
  • Preserve the existing not-found path by returning undefined when fuzzy results do not include an exact match.
  • Add coverage for multi-hit fuzzy results and fuzzy results with no exact-domain match.

Testing

  • pnpm --filter @shopify/app vitest src/cli/utilities/developer-platform-client/app-management-client.test.ts --run

@isaacroldan isaacroldan requested a review from a team as a code owner July 9, 2026 13:35
@github-actions github-actions Bot added cla-needed no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. labels Jul 9, 2026
@isaacroldan isaacroldan requested a review from a team as a code owner July 9, 2026 13:38
@isaacroldan isaacroldan removed the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Jul 9, 2026
@github-actions github-actions Bot added the Area: @shopify/app @shopify/app package issues label Jul 9, 2026
…atch

AppManagementClient.storeByDomain passed the domain as a fuzzy
`accessibleShops(search:)` argument and then returned `stores[0]`, so a
domain that is a substring of another store's domain (e.g.
`example.myshopify.com` vs `turbo-example.myshopify.com`) could resolve to
the wrong store. That store then gets cached to `dev_store_url` and
self-reinforces.

Match the normalized domain exactly instead of taking the first fuzzy hit,
returning undefined when nothing matches so the existing "could not find
store" error path is used. Adds tests for the multi-hit and no-exact-match
cases.

Co-authored-by: Isaac Roldan <isaac.roldan@shopify.com>
Assisted-By: devx/782ef931-ac0a-4cc4-bff1-a2511c379664
@isaacroldan isaacroldan force-pushed the store-by-domain-exact-match branch from 0b323f6 to 57eff80 Compare July 9, 2026 13:45
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