Skip to content

Make store auth session reuse opt-in per theme command - #8183

Merged
alfonso-noriega merged 1 commit into
mainfrom
theme-store-auth-opt-in
Jul 29, 2026
Merged

Make store auth session reuse opt-in per theme command#8183
alfonso-noriega merged 1 commit into
mainfrom
theme-store-auth-opt-in

Conversation

@alfonso-noriega

@alfonso-noriega alfonso-noriega commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Regression from #7783 (4.4.0), reported by Enterprise Support (Slack thread) and in the dev community forum.

Store-auth session reuse was added to the shared ThemeCommand.createSession, so every theme command with a password flag inherited it — while #7783 only intended it for theme pull and theme push. The base storeAuthScopes() returned [], and [].every(...) is always true, so commands like theme dev adopted any cached store auth session, including ones without theme scopes. The resulting 401 Invalid API key or access token / missing read_themes access scope errors were terminal, and shopify auth logout couldn't fix them (store-auth sessions live in a separate shopify-cli-store storage bucket).

WHAT is this pull request doing?

  • Changes the storeAuthScopes() contract to string[] | undefined: returning undefined (the default) opts the command out of store-auth session reuse entirely; commands opt in by declaring the scopes they require.
  • Only theme pull (read_themes) and theme push (read_themes, write_themes) opt in — matching Use store auth sessions for theme commands #7783's stated intent. theme dev and all other theme commands authenticate normally again.
  • Threads the required scopes explicitly through the session-lookup helpers instead of re-reading them via this.
  • Adds tests pinning that unscoped commands never read the store-auth cache (single- and multi-environment), and reworks existing tests to use a scoped test command where adoption is the behavior under test.

How to test your changes?

  1. shopify store auth --store <store> --scopes read_products (a session without theme scopes)
  2. shopify theme dev --store <store> — before: fails with missing read_themes access scope or 401; after: authenticates through the normal theme flow.
  3. shopify theme pull --store <store> after shopify store auth --store <store> --scopes read_themes,write_themes — still reuses the stored session (no login prompt).

Measuring impact

  • Existing analytics will cater for this addition

Store auth session reuse was added to the shared ThemeCommand base class,
so every theme command with a password flag inherited it, while only
theme pull and theme push declare the scopes they require. The base
storeAuthScopes() returned [], and requiredScopes.every() on an empty
array is always true, so commands like theme dev adopted any cached
store auth session, including ones without theme scopes, causing 401s
and missing-scope errors that could not be fixed via auth logout.

Commands now opt in to store auth session reuse by returning the scopes
they require from storeAuthScopes(); the default (undefined) opts the
command out entirely, so only theme pull and theme push reuse stored
store auth sessions.

Assisted-By: devx/60503589-d48c-43b2-8fba-b0df1e076f15

Copy link
Copy Markdown
Contributor

I think some other commands should still apply, like theme info and theme list

@alfonso-noriega
alfonso-noriega marked this pull request as ready for review July 28, 2026 14:56
@alfonso-noriega
alfonso-noriega requested review from a team as code owners July 28, 2026 14:56
@alfonso-noriega
alfonso-noriega added this pull request to the merge queue Jul 29, 2026
Merged via the queue into main with commit cc58d58 Jul 29, 2026
30 checks passed
@alfonso-noriega
alfonso-noriega deleted the theme-store-auth-opt-in branch July 29, 2026 14:15
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