Skip expired store auth sessions in theme commands - #8185
Merged
Conversation
1 task
Contributor
Author
This was referenced Jul 28, 2026
alfonso-noriega
marked this pull request as ready for review
July 28, 2026 14:56
isaacroldan
reviewed
Jul 28, 2026
isaacroldan
reviewed
Jul 28, 2026
Theme commands read stored store auth sessions with the raw cache accessor and never checked expiry, so an expired token was handed to the Admin API and the resulting 401 was terminal: the theme session carries no refresh handler and the failure path never falls back to normal authentication. Reuse isSessionExpired from cli-kit (including its refresh margin) so expired sessions are skipped and the command authenticates normally instead. Assisted-By: devx/60503589-d48c-43b2-8fba-b0df1e076f15
alfonso-noriega
force-pushed
the
theme-store-auth-require-recorded-scopes
branch
from
July 29, 2026 09:33
b492a9f to
ed332dd
Compare
alfonso-noriega
force-pushed
the
theme-store-auth-skip-expired
branch
from
July 29, 2026 09:33
6abd257 to
7bb01a9
Compare
Contributor
Differences in type declarationsWe 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:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/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).
|
isaacroldan
approved these changes
Jul 29, 2026
Base automatically changed from
theme-store-auth-require-recorded-scopes
to
main
July 29, 2026 14:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

WHY are these changes introduced?
Third layer of the
theme devstore-auth regression fix (Slack thread); stacked on #8184.Theme commands read stored store-auth sessions with the raw cache accessor and never checked expiry. An expired token was handed to the Admin API, and the resulting 401 was terminal: the theme session carries no refresh handler (
adminRequestDoconly installs one when'refresh' in session), and the failure path never falls back to normal authentication. This is the exact shape of the July 8 Enterprise case (401 onpublicApiVersionsthatauth logout+ re-auth couldn't fix).WHAT is this pull request doing?
isSessionExpired(including its 4-minute refresh margin) and falls back to normal theme authentication.does not check stored store auth cache session expiry) and adds a positive test for future expiries.isSessionExpiredimplementation runs.Actual token refresh (the refresh client lives in
@shopify/store, which@shopify/themedeliberately no longer depends on) is left as follow-up work.How to test your changes?
Covered by unit tests (
theme-command.test.ts): a stored session with a pastexpiresAtis skipped and the command authenticates normally; a futureexpiresAtis still reused.Measuring impact