Skip to content

Find a store in the account's only organization when destinations miss it - #9001

Open
egaodd wants to merge 1 commit into
mainfrom
river/store-commands-single-organization
Open

egaodd wants to merge 1 commit into
mainfrom
river/store-commands-single-organization

Conversation

@egaodd

@egaodd egaodd commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Found in the service accounts bug bash (P2): shopify store delete -s <store> failed with "Could not determine which organization owns " for any store the service account hadn't created itself, and store info said the store couldn't be found, even though both commands work with --organization-id and the token belongs to exactly one organization.

WHAT is this pull request doing?

Both commands locate a store's organization through Business Platform's destinations search, which only lists stores the account itself can open. A service account can open only the stores it created; a person can belong to an organization without a seat on every store. The Organizations API, which the commands use next, lists every store the account may manage, so the miss was in the lookup, not in the access.

When the destinations lookup comes up empty and the account belongs to one organization, that organization is used, the way store list already auto-selects it:

  • store delete goes straight to it instead of failing non-interactively or prompting. The organizations are listed with the same token the lookup used, with noPrompt in non-interactive runs, so a CI run with no login still gets a clean error rather than an attempt to prompt.
  • store info looks the store up through the Organizations API there, and still reports not-found when that misses too.
  • Accounts in several organizations keep the prompt and the --organization-id requirement.

Not changed, for a separate decision: store create dev still requires --organization-id non-interactively (requiredIfNonInteractive) even for a single-organization account, which contradicts the flag's own "Auto-selects if you belong to a single organization".

How to test your changes?

Verified against production with two dev-store service accounts in org 299069: token A created river-fix-store-1; with token B, shopify store info --store river-fix-store-1.myshopify.com returned the store and shopify store delete -s river-fix-store-1.myshopify.com -f deleted it, both without --organization-id.

Unit tests in store-lookup/organization.test.ts (single-org fallback, non-interactive token reuse, no organizations, multi-org prompt) and services/store/info/index.test.ts (fallback hit, not-found-either, failing org lookup). tsc and eslint pass on store and organizations.

Measuring impact

  • n/a (bug fix)

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • Changeset added (@shopify/cli: patch)

…s it

`store delete -s <store>` failed with "Could not determine which
organization owns <store>" for any store the service account hadn't
created itself, and `store info` said the store couldn't be found, even
though the same commands worked with `--organization-id` and the token
belongs to exactly one organization.

Both commands locate a store's organization through Business Platform's
destinations search, which only lists stores the account itself can
open. A service account can open only the stores it created; a person
can belong to an organization without a seat on every store. The
Organizations API, which the commands then use, lists every store the
account may manage, so the miss was in the lookup, not the access.

When the destinations lookup comes up empty and the account belongs to
one organization, that organization is used, the way `store list`
already auto-selects it. `store delete` goes straight to it instead of
failing non-interactively or prompting. `store info` looks the store up
through the Organizations API there, and still reports the store as not
found when that misses too. Accounts in several organizations keep the
prompt and the `--organization-id` requirement.

Co-authored-by: Eddie Gao <eddie.gao@shopify.com>
@egaodd
egaodd requested a review from a team as a code owner October 23, 2026 16:01
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 23, 2026
// eslint-disable-next-line no-catch-all/no-catch-all
} catch (error) {
outputDebug(`BP Organizations shop lookup in ${organization.businessName} failed: ${errorMessage(error)}`)
return undefined

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted review — nonblocking

Could we preserve permission/authentication and unexpected API errors here, rather than treating them as a lookup miss? For example, an OrganizationStoreAccessError gets caught and replaced with “store not found,” hiding the guidance about granting dev-store access.

fetchOptionalOrganizationShop already returns undefined when the store genuinely isn’t found, so we can keep that fallback while letting other failures surface, consistent with the error-handling guidance.

@egaodd
egaodd enabled auto-merge October 23, 2026 20:46

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants