Skip to content

Conversation

@dmerand
Copy link
Contributor

@dmerand dmerand commented Dec 3, 2025

WHY are these changes introduced?

Addresses feedback from internal Slack discussion: https://shopify.slack.com/archives/C05E3BDFDRB/p1764604207635019

Also fixes community forum issue: https://community.shopify.dev/t/cli-cant-access-another-stores-account/26483

Problem: When users log out and log in with a different account, the CLI tries to use the cached store from the previous account. This results in confusing error messages that don't explain:

  1. The user is logged into a different account/organization
  2. They can use --store to select a different store
  3. They can use shopify auth login to switch back to the account with access

WHAT is this pull request doing?

Improves error messages in three locations where store access errors occur:

1. App Dev - Store Not Found in Organization

File: packages/app/src/cli/services/dev/fetch.ts

When a cached store doesn't exist in the current organization (lines 128-137).

Before:

Could not find Store for domain example.myshopify.com in Organization Acme Corp.

After:

Your current account (Acme Corp) doesn't have access to store example.myshopify.com.

Next steps:
• Select a different store with --store or --reset
• Use shopify auth login to log in with a different account that has access to this store

2. Theme/App Dev - Invalid Target Authentication Error

File: packages/cli-kit/src/private/node/session/exchange.ts

When token exchange fails with invalid_target (lines 213-220).

Before:

You are not authorized to use the CLI to develop in the provided store: example.myshopify.com.

Next steps:
• Ensure you have logged in to the store using the Shopify admin at least once.
• Ensure you are the store owner, or have a staff account...
• Ensure you are using the permanent store domain, not a vanity domain.

After: (Added two new suggestions at the top)

You are not authorized to use the CLI to develop in the provided store: example.myshopify.com.

Next steps:
• Select a different store with --store
• Use shopify auth login to log in with a different account that has access to this store
• Ensure you have logged in to the store using the Shopify admin at least once.
• Ensure you are the store owner, or have a staff account...
• Ensure you are using the permanent store domain, not a vanity domain.

3. Theme Dev - 403 Admin API Access Error

File: packages/cli-kit/src/public/node/api/admin.ts

When accessing the Admin API returns 403 (lines 172-185). This is the exact error from the community forum post.

Before:

Looks like you don't have access this dev store: (store-name).
If you're not the owner, create a dev store staff account for yourself

After:

Looks like you don't have access to this store: store.myshopify.com

Next steps:
• Select a different store with --store
• Use shopify auth login to log in with a different account that has access to this store
• If you're not the owner, create a dev store staff account for yourself

Tests Added/Updated

  • Updated fetch.test.ts: Existing test updated to match new error message ✅
  • Added admin.test.ts: New test for 403 admin API error case ✅
  • No changes needed to exchange.test.ts: Tests still pass ✅

All 29 tests passing across modified files.

How to test your changes?

Scenario 1: App dev with wrong account

  1. Create an app project linked to account A
  2. Run shopify auth logout then shopify auth login with account B
  3. Run shopify app dev
  4. Verify error message suggests --store and shopify auth login

Scenario 2: Theme dev with wrong account

  1. Run shopify theme dev with store from account A
  2. Run shopify auth logout then shopify auth login with account B
  3. Run shopify theme dev
  4. Verify error message suggests --store and shopify auth login

Scenario 3: Using --store flag

  1. After seeing the error, run shopify app dev --store other-store.myshopify.com
  2. Verify command works with explicitly specified store

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

dmerand commented Dec 3, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.16% (-0.07% 🔻)
13819/17457
🟡 Branches
73.12% (+0.01% 🔼)
6742/9221
🟡 Functions
79.31% (-0.06% 🔻)
3546/4471
🟡 Lines
79.53% (-0.05% 🔻)
13061/16423
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / admin-as-app.ts
100% 100% 100% 100%
🟢
... / bulk-operation-run-mutation.ts
100% 100% 100% 100%
🟢
... / bulk-operation-run-query.ts
100% 100% 100% 100%
🟢
... / get-bulk-operation-by-id.ts
100% 100% 100% 100%
🟢
... / staged-uploads-create.ts
100% 100% 100% 100%
🔴
... / status.ts
0% 100% 0% 0%
🔴
... / pull.ts
0% 100% 0% 0%
🔴
... / pull.ts
0% 0% 0% 0%
🟢
... / bulk-operation-status.ts
96% 85.71% 100% 100%
🟢
... / download-bulk-operation-results.ts
100% 100% 100% 100%
🟢
... / execute-bulk-operation.ts
90.91% 80.56% 100% 92.31%
🟢
... / format-bulk-operation-status.ts
100% 100% 100% 100%
🟢
... / run-mutation.ts
100% 100% 100% 100%
🟢
... / run-query.ts
100% 100% 100% 100%
🟡
... / stage-file.ts
72.73% 62.5% 83.33% 71.88%
🟢
... / watch-bulk-operation.ts
100% 100% 100% 100%
🔴
... / promiseWithResolvers.ts
33.33% 50% 50% 33.33%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / execute.ts
0%
0% (-100% 🔻)
0% 0%
🟢
... / extension-instance.ts
84.8% (+0.23% 🔼)
77.6% (-0.91% 🔻)
92.06% (+0.13% 🔼)
85.11% (+0.24% 🔼)
🟡
... / specification.ts
69.09%
75.61% (+2.44% 🔼)
76.47% (-1.31% 🔻)
68.75%
🟢
... / ui_extension.ts
85.38% (-9.44% 🔻)
72.34% (-8.91% 🔻)
84% (-16% 🔻)
88% (-8.46% 🔻)
🟢
... / developer-platform-client.ts
84.62% (-1.5% 🔻)
73.68% (+3.1% 🔼)
81.82% (+1.82% 🔼)
90.63% (-2.71% 🔻)
🟢
... / api.ts
87.07% (-0.43% 🔻)
76.71% (-0.1% 🔻)
100%
86.49% (-0.43% 🔻)
🟢
... / ConcurrentOutput.tsx
98.36% (-1.64% 🔻)
92% (-4% 🔻)
100%
98.33% (-1.67% 🔻)
🔴
... / ui.tsx
50.82% (-0.79% 🔻)
42.86% (-5.53% 🔻)
54.55% (+1.42% 🔼)
50% (-0.82% 🔻)
🟢
... / console.ts
81.82% (+15.15% 🔼)
75% (-25% 🔻)
100% (+33.33% 🔼)
81.82% (+15.15% 🔼)
🔴
... / dev.ts
14.29% (+0.95% 🔼)
3.13% (+0.18% 🔼)
50% (-7.14% 🔻)
14.29% (+0.95% 🔼)
🟢
... / init.ts
88% (-0.89% 🔻)
71.43% (+4.76% 🔼)
86.67% (+4.85% 🔼)
88% (-0.89% 🔻)
🟡
... / theme-polling.ts
67.12% (-0.93% 🔻)
68.75% 78.57%
66.67% (-0.98% 🔻)

Test suite run success

3443 tests passing in 1395 suites.

Report generated by 🧪jest coverage report action from 4fb2fb4

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant