Fix storeByDomain connecting to the wrong store on substring domain match#8043
Open
isaacroldan wants to merge 2 commits into
Open
Fix storeByDomain connecting to the wrong store on substring domain match#8043isaacroldan wants to merge 2 commits into
isaacroldan wants to merge 2 commits into
Conversation
…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
0b323f6 to
57eff80
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
AppManagementClient.storeByDomainusedaccessibleShops(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 indev_store_url.What
shopDomainmatches exactly.undefinedwhen fuzzy results do not include an exact match.Testing
pnpm --filter @shopify/app vitest src/cli/utilities/developer-platform-client/app-management-client.test.ts --run