Conversation
#8183 made store auth session reuse opt-in per theme command to stop commands adopting standard store auth sessions with insufficient scopes. The default (no declared scopes) also stopped theme commands from reusing CLI-minted preview store sessions, so commands like `theme list` fell through to device authentication. A preview store cannot complete that flow and has no other credential. Reuse preview sessions regardless of the declared scopes. Keep the scope requirement for standard sessions, so #8183's fix still holds. Assisted-By: devx/e5be4a75-315f-44ac-9b24-78944589ddd8
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved blocking issues were identified.
Pull request overview
This pull request reuses cached preview-store sessions across theme commands while preserving scope checks for standard sessions.
Changes:
- Adds preview-session reuse for single- and multi-environment commands.
- Preserves standard-session scope validation.
- Adds regression tests and a patch changeset.
File summaries
| File | Description |
|---|---|
packages/theme/src/cli/utilities/theme-command.ts |
Implements preview-session reuse and standard-session filtering. |
packages/theme/src/cli/utilities/theme-command.test.ts |
Adds preview and standard session coverage. |
.changeset/tidy-preview-store-sessions.md |
Documents the user-facing fix. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
/snapit |
1 similar comment
|
/snapit |
|
🫰✨ Thanks @dmerand! 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-20260914205340Caution After installing, validate the version by running |
|
🫰✨ Thanks @dmerand! 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-20260914205309Caution After installing, validate the version by running |
There was a problem hiding this comment.
Went through this against the history. The preview-session bypass is the right shape, and better than opting each command in one at a time, which is what I'd suggested in the Slack thread. #7783 says the store-auth cache was built for preview stores in the first place, and #8183's gate was aimed at standard sessions. Splitting the two paths restores that intent, and it won't drift when someone adds a new theme command.
Checked the back-compat case too: kind: 'preview' has been written since 4.3.0, the first release with store create preview, so no stored session reads back as standard by accident.
Two inline notes below. Neither blocks the fix landing if you'd rather file them as follow-ups.
| )}; needs: ${requiredScopes.join(', ')}).`, | ||
| ) | ||
| return undefined | ||
| const isPreviewSession = storedSession.kind === 'preview' |
There was a problem hiding this comment.
Worth thinking about what this does to a stale preview session, the one from a store that's since been claimed. Before this PR it broke theme pull and theme push. After it, every theme command.
There's no way for a user to clear it. shopify auth logout is just sessionStore.remove() (packages/cli-kit/src/public/node/session.ts:327) and never touches the shopify-cli-store storage, and there's no store auth logout. The only clear that exists today is the side effect in shopify store info (packages/store/src/cli/services/store/info/index.ts:166), which fires on a 401/404 from the preview-store API. Nobody is going to find that.
That's the failure mode #8183's commit message called out, 401s that can't be fixed with auth logout. #8390 is one answer, but the concern raised in the thread about clear-on-401 being unrecoverable for an unclaimed store still stands. A shopify store auth logout --store <store> would cover it without that risk.
There was a problem hiding this comment.
Deferring this from #8546. #8390 already clears the stored preview session on a 401 and points to store auth, so it covers the main path. Two notes: (1) #8390 is still a draft, so landing order matters — if #8546 lands first there is a window with no manual clear; (2) the residual concern stands: clear-on-401 is unrecoverable for an unclaimed store, and store auth logout --store would cover it without that risk. Keeping both as follow-ups.
gonzaloriestra
left a comment
There was a problem hiding this comment.
Works as expected 👌
WHY are these changes introduced?
A preview store from
shopify store create previewstores an Admin API token in the store-auth cache. A preview store cannot complete a device login and has no password, so that token is its only credential.#8183 made store auth session reuse opt-in per theme command, to stop commands from adopting standard store auth sessions with insufficient scopes. Its opt-out default also stopped every theme command except
theme pullandtheme pushfrom reusing the cached preview token. Commands such astheme listfell through to device authentication, which the user cannot complete. The command is then a dead end.Regression from 4.6.0. Reported in Slack.
WHAT is this pull request doing?
kind: 'preview'session in every theme command, whateverstoreAuthScopes()returns.validateEnvironmentsdropped them for the same reason.theme pullandtheme pushkeep their declared scopes, so they also reuse standard sessions.How to manually test your changes?
Seed a session with
kind: 'preview'andscopes: [], then run a command that does not opt in to store auth reuse:Result with this branch:
Result on
main:Ensuring that the user is authenticated with the Theme APIfollowed byYou are not authorized to use the CLI to develop in the provided store.theme pullandtheme pushagainst a preview store still reuse the stored session.Checklist
patch) and added a changesetFollow-up: #8547 adds the skipped-session reason to authentication errors.