Skip to content

Name the skipped store auth session in theme auth errors - #8547

Draft
dmerand wants to merge 2 commits into
donald/theme-preview-session-reusefrom
donald/theme-preview-session-reuse-next-steps
Draft

dmerand wants to merge 2 commits into
donald/theme-preview-session-reusefrom
donald/theme-preview-session-reuse-next-steps

Conversation

@dmerand

@dmerand dmerand commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Stacked on #8546.

When a theme command skips a stored store auth session and falls back to device authentication, it reports the skip reason only through outputDebug. Without --verbose, the user cannot see that a session sat in the cache. A device login cannot replace a preview store session, so the silent fall-through costs the user all recovery options.

WHAT is this pull request doing?

  • Record why each stored session was skipped: expired, standard session, or missing scopes.
  • Attach the reason and a recovery step to the next steps of the authentication error.
  • Pass errors through unchanged when no session was skipped, or when the error is not an AbortError.

The recovery step matches the reason. A standard session points to --password. Missing scopes point to shopify store auth --scopes.

How to manually test your changes?

Seed a standard session with scopes: ['read_products'], which theme pull rejects, then run the command.

CI=true shopify theme pull --store <store>.myshopify.com --development --verbose

Result with this branch:

Authorization is required to continue, but the current environment does not support interactive prompts.
...
Next steps
  • The CLI found a stored store auth session for <store>.myshopify.com, but did not use it: it is missing required scopes (has: read_products; needs: read_themes).
  • Run `shopify store auth --store <store>.myshopify.com --scopes read_themes` to grant the required scopes.

Result on main: the same error without the two next steps.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch) and added a changeset

When a theme command skips a stored store auth session and then falls
back to device authentication, the skip reason only appeared with
--verbose. Device authentication cannot replace a preview store
session, so the user had no way to see why the stored session was
ignored.

Attach the reason and a recovery step to the next steps of the
authentication error.

Assisted-By: devx/e5be4a75-315f-44ac-9b24-78944589ddd8
@dmerand
dmerand requested a review from a team as a code owner September 14, 2026 20:47
@github-actions github-actions Bot added the Area: @shopify/theme @shopify/theme package issues label Sep 14, 2026
@dmerand
dmerand added this pull request to stack #8548 September 14, 2026 20:50

@tizmagik tizmagik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Direction is right. Four inline notes below, on the advice strings and the plumbing.

Comment thread packages/theme/src/cli/utilities/theme-command.ts Outdated
Comment thread packages/theme/src/cli/utilities/theme-command.ts Outdated
Comment thread packages/theme/src/cli/utilities/theme-command.ts Outdated
Comment thread packages/theme/src/cli/utilities/theme-command.ts Outdated
Thread the store auth session result through the multi-environment
pre-pass, so an environment no longer re-reads the cached session
after validation discarded the skipped reason.

Preserve the original AbortError when attaching next steps, so an
error subclass and its extra fields survive.

Give an expired preview session no `store auth` advice, which cannot
run while a preview session is present. Trim the standard-session
advice to the `--password` recovery step.

Add tests for the preview scope bypass, each skip reason, error
identity, non-AbortError pass-through, and single derivation in
multi-environment commands. Correct the changeset wording.

Assisted-By: devx/e5be4a75-315f-44ac-9b24-78944589ddd8
Copilot AI lite review requested due to automatic review settings September 15, 2026 17:05

Copilot AI left a comment

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.

🟡 Changes recommended

Three unresolved moderate issues affect error propagation and recovery guidance.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR improves theme authentication errors by explaining skipped cached sessions and suggesting recovery actions.

Changes:

  • Records expired, standard, and insufficient-scope session reasons.
  • Adds contextual recovery steps to authentication errors.
  • Adds regression tests and a patch changeset.

Review findings:

  • Moderate (2 votes): Multi-environment errors drop AbortError.nextSteps.
  • Moderate (1 vote): theme profile cannot recover using --password.
  • Moderate (2 votes): Expired-session advice is invalid for commands without storeAuthScopes().
File summaries
File Summary
packages/theme/src/cli/utilities/theme-command.ts Tracks skipped sessions and enriches authentication errors.
packages/theme/src/cli/utilities/theme-command.test.ts Tests session reuse, skip reasons, and error propagation.
.changeset/name-skipped-store-auth-session.md Documents the user-facing patch release.
Review details

Suppressed comments (1)

packages/theme/src/cli/utilities/theme-command.ts:465

  • theme profile also takes this no-scope path, but its service rejects every --password value (packages/theme/src/cli/services/profile.ts:25-30). Following this new recovery step therefore leads to another error instead of recovering; the advice needs to be omitted or specialized for commands that cannot use a password.
        return {skipped: {reason, advice: 'Pass a Theme Access password with `--password`.'}}
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

const store = flags.store as string
await useThemeStoreContext(store, async () => {
const session = requiresAuth ? await this.createSession(flags, storeAuthSession) : undefined
const session = requiresAuth ? await this.createSession(flags, storeAuthResult) : undefined
Comment on lines +454 to +456
advice: isPreviewSession
? undefined
: `Run \`shopify store auth --store ${storeFqdn}\` to store a fresh session.`,
@gonzaloriestra

Copy link
Copy Markdown
Contributor

/snapit

@github-actions

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! 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-20260917115034

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@dmerand
dmerand marked this pull request as draft September 17, 2026 15:30
@dmerand

dmerand commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

I've converted this one to a draft while I revisit the scope of this change. The downstack PR is the more important unblocker.

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

Labels

Area: @shopify/theme @shopify/theme package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants