Repository navigation
[stable/5.2] Fail Patch provenance with a message when git can't read - #9234
Merged
Merged
Conversation
A failed git ls-remote or fetch fails the check with git's message and the usual summary, instead of ending the job with a stack trace. hasFile reads trees with git ls-tree, which fails on a failed read, so a failed read fails the check instead of reading as a missing path. Both git ls-tree calls read paths literally, as git rev-parse <commit>:<path> did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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/common/version.d.ts@@ -1 +1 @@
-export declare const CLI_KIT_VERSION = "5.2.0";
\ No newline at end of file
+export declare const CLI_KIT_VERSION = "5.2.1";
\ No newline at end of file
packages/cli-kit/dist/private/node/cli-version-cache.d.ts@@ -1,25 +1,5 @@
import { PackageVersionKey } from './conf-store.js';
export declare function resolveCLIRegistry(): Promise<string>;
export declare function getCLIVersionCacheKey(registry: string, versionRange?: string): PackageVersionKey;
-export declare function getCLINodeRangeCacheKey(registry: string): PackageVersionKey;
export declare function getPublicCLIVersionCacheKey(registry: string, versionRange?: string): PackageVersionKey;
-export declare function getCachedCLIVersion(versionRange?: string, registry?: string | undefined): string | undefined;
-/**
- * The cache entry for the Node range in a release's `engines`. It names the release, because other lookups refresh
- * the latest version on their own and must not inherit another release's range.
- *
- * @param version - The release the range belongs to.
- * @param nodeRange - Its `engines.node`, if it declares one.
- * @returns The value to cache under {@link getCLINodeRangeCacheKey}.
- */
-export declare function cliNodeRangeCacheValue(version: string, nodeRange: string | undefined): string;
-/**
- * The Node range in the `engines` of `version`, from a fresh entry the version lookup cached for that release.
- * Undefined when the release declares none, or when nothing fresh is cached for it.
- */
-export declare function getCachedCLINodeRange(version: string, registry?: string | undefined): string | undefined;
-/**
- * Whether a release whose `engines.node` is `nodeRange` supports the running Node. A release that declares no range
- * supports it.
- */
-export declare function supportsRunningNode(nodeRange: string | undefined): boolean;
\ No newline at end of file
+export declare function getCachedCLIVersion(versionRange?: string, registry?: string | undefined): string | undefined;
\ No newline at end of file
packages/cli-kit/dist/private/node/cli-version-check.d.ts@@ -1,14 +1,8 @@
interface CLIVersions {
latest?: string;
currentMajor?: string;
- /** The Node range in the latest release's `engines`, when it declares one. */
- latestNodeRange?: string;
}
export declare function getCachedCurrentMajorCLIVersion(): string | undefined;
-/**
- * The Node range in the `engines` of the cached latest release, when the version lookup cached one for it.
- */
-export declare function getCachedLatestCLINodeRange(): string | undefined;
export declare function checkForCLIVersions({ includeCurrentMajor }?: {
includeCurrentMajor?: boolean | undefined;
}): Promise<CLIVersions>;
packages/cli-kit/dist/private/node/session.d.ts@@ -61,53 +61,21 @@ export interface OAuthSession {
appManagement?: string;
userId: string;
}
-/**
- * What a command analytics user ID identifies:
- *
- * - `account`: a Shopify account UUID.
- * - `store_admin_user`: the numeric ID of a user of a store's admin.
- * - `preview_store_shop`: the shop ID that a preview store created without an account reports.
- * - `credential`: a pseudonym derived from a token or a password.
- */
-export type UserIdKind = 'account' | 'store_admin_user' | 'preview_store_shop' | 'credential';
-/** A command analytics user ID and what it identifies. `kind` is `undefined` when that is not known. */
-interface AnalyticsUserId {
- id: string;
- kind: UserIdKind | undefined;
-}
type AuthMethod = 'partners_token' | 'service_account_token' | 'device_auth' | 'theme_access_token' | 'custom_app_token' | 'none';
/**
- * Retrieves a stable user identifier for analytics, and what it identifies, from one decision, so that the kind always
- * describes the ID that is returned.
+ * Retrieves a stable user identifier for analytics, or `'unknown'` if none applies.
*
* Evaluation order:
- * 1. If an automation token or theme token variable is set, returns a deterministic UUID derived from that secret, of
- * kind `credential`.
- * 2. Otherwise, if `setLastSeenUserIdAfterAuth` was called (e.g. after OAuth), returns that ID and the kind recorded
- * with it.
- * 3. Otherwise, if a persisted CLI session ID is available, returns it, of kind `account`.
- * 4. Otherwise returns `'unknown'`, of no kind.
- *
- * @returns A Promise that resolves to the user ID and its kind.
- */
-export declare function getLastSeenUserIdWithKindAfterAuth(): Promise<AnalyticsUserId>;
-/**
- * Retrieves a stable user identifier for analytics, or `'unknown'` if none applies. The ID is the one that
- * `getLastSeenUserIdWithKindAfterAuth` returns, in the same evaluation order.
+ * 1. If an app automation token or theme token is used, returns a deterministic UUID
+ * derived from that secret.
+ * 2. Otherwise, if `setLastSeenUserIdAfterAuth` was called (e.g. after OAuth), returns that value.
+ * 3. Otherwise, if a persisted CLI session id is available, returns it.
+ * 4. Otherwise returns `'unknown'`.
*
* @returns A Promise that resolves to the user ID as a string.
*/
export declare function getLastSeenUserIdAfterAuth(): Promise<string>;
-/**
- * Records the user ID of the command analytics event and what that ID identifies.
- *
- * `getLastSeenUserIdWithKindAfterAuth` returns the kind only together with this ID. A token variable takes precedence
- * over both, so that the kind never describes an ID that the event does not report.
- *
- * @param id - The user ID.
- * @param kind - What the user ID identifies. `undefined` records that it is not known.
- */
-export declare function setLastSeenUserIdAfterAuth(id: string, kind: UserIdKind | undefined): void;
+export declare function setLastSeenUserIdAfterAuth(id: string): void;
/**
* Retrieves the last seen authentication method used in the current session.
*
packages/cli-kit/dist/public/node/base-command.d.ts@@ -15,14 +15,6 @@ declare abstract class BaseCommand extends Command {
static descriptionWithMarkdown?: string;
static jsonOutputSchema?: JsonOutputSchema;
static get requiresSyncAnalytics(): boolean;
- /**
- * Whether the command's error messages are left out of the analytics event sent to the event collector, because they
- * can quote flag values that hold user data. The value is read before the flags are parsed, so it also covers an
- * error raised by flag parsing.
- *
- * @returns `true` to leave the command's error messages out.
- */
- static get withholdsErrorMessageFromAnalytics(): boolean;
static nonTTYFlagRequirements(_flags: FlagOutput): NonTTYFlagRequirement[];
static descriptionForHelp(): string | undefined;
/** @deprecated Use descriptionForHelp instead. */
packages/cli-kit/dist/public/node/metadata.d.ts@@ -43,13 +43,6 @@ declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
startTopic?: string;
startArgs: string[];
requiresSyncAnalytics?: boolean;
- withholdsErrorMessageFromAnalytics?: boolean;
- };
- graphqlExecute: {
- operation_type?: "query" | "mutation" | "unknown";
- query_source?: "inline" | "file";
- allow_mutations_flag_used?: boolean;
- variables_used?: boolean;
};
} & {
environmentFlags: string;
@@ -72,13 +65,6 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
startTopic?: string;
startArgs: string[];
requiresSyncAnalytics?: boolean;
- withholdsErrorMessageFromAnalytics?: boolean;
- };
- graphqlExecute: {
- operation_type?: "query" | "mutation" | "unknown";
- query_source?: "inline" | "file";
- allow_mutations_flag_used?: boolean;
- variables_used?: boolean;
};
} & {
environmentFlags: string;
@@ -100,13 +86,6 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
startTopic?: string;
startArgs: string[];
requiresSyncAnalytics?: boolean;
- withholdsErrorMessageFromAnalytics?: boolean;
- };
- graphqlExecute: {
- operation_type?: "query" | "mutation" | "unknown";
- query_source?: "inline" | "file";
- allow_mutations_flag_used?: boolean;
- variables_used?: boolean;
};
} & {
environmentFlags: string;
packages/cli-kit/dist/public/node/session.d.ts@@ -20,11 +20,8 @@ export type AccountInfo = UserAccountInfo | ServiceAccountInfo | UnknownAccountI
* Records the user ID that should be attached to command analytics for this process.
*
* @param userId - User identifier to report on the command analytics event.
- * @param kind - What the user ID identifies: a Shopify account UUID (`account`), the numeric ID of a user of a store's
- * admin (`store_admin_user`), the shop ID that a preview store created without an account reports
- * (`preview_store_shop`), or a pseudonym derived from a token or a password (`credential`). Omit it when it is not known.
*/
-export declare function setLastSeenUserId(userId: string, kind?: 'account' | 'store_admin_user' | 'preview_store_shop' | 'credential'): void;
+export declare function setLastSeenUserId(userId: string): void;
/**
* Finds a stored Shopify account session by alias without changing the current session.
*
packages/cli-kit/dist/public/node/store-auth-session.d.ts@@ -103,17 +103,6 @@ export declare function clearStoredStoreAppSession(store: string, userIdOrStorag
* @returns An Admin session, or undefined when no usable session is cached.
*/
export declare function getStoreAuthAdminSession(store: string, storage?: LocalStorage<StoreAuthSessionSchema>): AdminSession | undefined;
-/**
- * What the user ID of a stored store auth session identifies, for command analytics.
- *
- * - A standard session's user ID is the numeric ID of a user of the store's admin.
- * - A preview store created without an account reports its shop ID as the user ID.
- * - A preview store created with a placeholder account reports that account's UUID.
- *
- * @param session - The stored store auth session.
- * @returns The kind of the session's user ID.
- */
-export declare function storedSessionUserIdKind(session: StoredStoreAppSession): 'account' | 'store_admin_user' | 'preview_store_shop';
/**
* Check whether a stored store auth session is expired, including the refresh margin.
*
|
dmerand
approved these changes
Dec 4, 2026
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?
The
stable/5.2copy of #9233, the same file. Two follow-ups from the review of #9228:git ls-remoteor fetch failed, the job ended with a stack trace and no summary. It failed closed, but didn't say why.hasFileread any git error as a missing path. A missing oclif manifest, for example, skips that file's version check, so a failed read of a tree has to fail the check, as a failed read of a file's text already does. With every commit and tree fetched that shouldn't happen, but the check shouldn't depend on it.WHAT is this pull request doing?
git ls-remoteor fetch fails the check with git's message, for example "Fetching stable/5.2, the pull request and main failed: …", and writes the usual summary.hasFileusesgit ls-tree, which prints nothing for a missing path and fails on a failed read. A failed read fails the check with its message.git ls-treecalls read paths literally (--literal-pathspecs), asgit rev-parse <commit>:<path>did.Nothing else changes. Checked locally: the 35 cases from earlier reviews give the same results and messages as the current file, with every
ghcall refused. Four new cases fail with a message: a failed read of a tree for a Version Packages bump that leaves both oclif manifests behind (the current file passes it), the same for a backport's changeset, and a failed fetch andls-remote(the current file ends without a message). Patch provenance fails here by design, since this pull request changes.github/.How to manually test your changes?
Run the check against a repository that doesn't exist (needs git and Node):
It fails at once with "Reading the head of stable/5.2 failed: remote: Repository not found. …", and the summary says the same. With the current file, the same command ends with a stack trace and an empty summary.
🤖 Generated with Claude Code