Skip to content

Require recorded scopes to reuse a store auth session in theme commands - #8184

Merged
alfonso-noriega merged 1 commit into
mainfrom
theme-store-auth-require-recorded-scopes
Jul 29, 2026
Merged

Require recorded scopes to reuse a store auth session in theme commands#8184
alfonso-noriega merged 1 commit into
mainfrom
theme-store-auth-require-recorded-scopes

Conversation

@alfonso-noriega

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

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Second layer of the theme dev store-auth regression fix (Slack thread); stacked on #8183.

hasRequiredStoreAuthScopes treated a stored session with no recorded scopes as satisfying any requirement (if (scopes.length === 0) return true), so theme pull/theme push could adopt sessions whose actual grant is unknown and fail later with missing-scope errors.

WHAT is this pull request doing?

  • Removes the empty-scopes escape hatch: a stored session must record scopes that satisfy the command's declared requirements to be reused.
  • Both shopify store auth and shopify store create preview always record granted scopes, so an empty scope list means the grant can't be verified — the command now falls back to normal theme authentication instead (graceful, no error).
  • Flips the test that pinned the old behavior.

How to test your changes?

Covered by unit tests (theme-command.test.ts): a stored session with scopes: [] no longer satisfies theme pull/theme push; the command falls back to ensureAuthenticatedThemes.

Measuring impact

  • Existing analytics will cater for this addition

alfonso-noriega commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Comment thread .changeset/theme-store-auth-require-recorded-scopes.md Outdated
Comment thread packages/theme/src/cli/utilities/theme-command.ts
hasRequiredStoreAuthScopes treated a stored session with no recorded
scopes as satisfying any requirement, so theme pull and theme push could
adopt sessions whose actual grant is unknown. Both store auth and
preview store creation always record scopes, so an empty scope list
means we cannot verify the grant; fall back to normal theme
authentication instead.

Assisted-By: devx/60503589-d48c-43b2-8fba-b0df1e076f15
@alfonso-noriega
alfonso-noriega force-pushed the theme-store-auth-require-recorded-scopes branch from b492a9f to ed332dd Compare July 29, 2026 09:33
@github-actions github-actions Bot added no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. and removed Area: @shopify/theme @shopify/theme package issues labels Jul 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/api/partners.d.ts
@@ -1,5 +1,7 @@
 import { GraphQLVariables, GraphQLResponse, CacheOptions, UnauthorizedHandler } from './graphql.js';
 import { RequestModeInput } from '../http.js';
+import { Variables } from 'graphql-request';
+import { TypedDocumentNode } from '@graphql-typed-document-node/core';
 /**
  * Executes a GraphQL query against the Partners API.
  *
@@ -12,6 +14,17 @@ import { RequestModeInput } from '../http.js';
  * @returns The response of the query of generic type <T>.
  */
 export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions, preferredBehaviour?: RequestModeInput, unauthorizedHandler?: UnauthorizedHandler): Promise<T>;
+/**
+ * Executes a GraphQL query against the Partners API. Uses typed documents.
+ *
+ * @param query - GraphQL query to execute.
+ * @param token - Partners token.
+ * @param variables - GraphQL variables to pass to the query.
+ * @param preferredBehaviour - Preferred behaviour for the request.
+ * @param unauthorizedHandler - Optional handler for unauthorized requests.
+ * @returns The response of the query of generic type <TResult>.
+ */
+export declare function partnersRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, preferredBehaviour?: RequestModeInput, unauthorizedHandler?: UnauthorizedHandler): Promise<TResult>;
 /**
  * Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)
  * if `response.extensions.deprecations` objects contain a `supportedUntilDate` (ISO 8601-formatted string).

Base automatically changed from theme-store-auth-opt-in to main July 29, 2026 14:15
@alfonso-noriega
alfonso-noriega added this pull request to the merge queue Jul 29, 2026
Merged via the queue into main with commit 8d3d45c Jul 29, 2026
27 checks passed
@alfonso-noriega
alfonso-noriega deleted the theme-store-auth-require-recorded-scopes branch July 29, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants