Skip to content

Stop reporting gateway errors as CLI crashes - #8329

Open
isaacroldan wants to merge 1 commit into
mainfrom
fix-500-reports
Open

Stop reporting gateway errors as CLI crashes#8329
isaacroldan wants to merge 1 commit into
mainfrom
fix-500-reports

Conversation

@isaacroldan

@isaacroldan isaacroldan commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Raw graphql-request ClientError objects can reach the top-level reporter when a call site uses handleErrors: false. For HTTP 502, 503, and 504, that records an infrastructure failure as an unexpected CLI bug.

Classify these gateway statuses as expected in shouldReportErrorAsUnexpected, consistent with the handled path that maps 5xx responses to AbortError. HTTP 500 keeps its existing classification.

Testing

  • pnpm --filter @shopify/cli-kit vitest run src/public/node/error.test.ts
  • pnpm --filter @shopify/cli-kit type-check
  • ESLint on the two changed files

@github-actions github-actions Bot added cla-needed Area: @shopify/cli @shopify/cli package issues labels Aug 14, 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

packages/cli-kit/dist/private/node/api/gateway-status.d.ts
/**
 * Pure helpers for classifying HTTP statuses that come from the gateway in front of an API rather
 * than from the API itself.
 *
 * This module is intentionally dependency-free: it is imported by both the request layer
 * (`../api.ts`) and the crash-report suppression logic (`../../public/node/error.ts`).
 * `error.ts` cannot import `../api.ts` directly — that would pull `graphql-request` into the
 * module graph of every command, and `api.ts → headers.ts → error.ts` is already a cycle — so the
 * shared status logic lives here, where it imports nothing from cli-kit.
 */
/**
 * Whether an HTTP status indicates a gateway-level failure in front of the API.
 *
 * @param status - The HTTP status of the response, if known.
 * @returns True when the status is 502, 503 or 504.
 */
export declare function isGatewayErrorStatus(status: number | undefined): boolean;

Existing type declarations

packages/cli-kit/dist/private/node/api.d.ts
@@ -12,6 +12,7 @@ export type NetworkRetryBehaviour = {
 type RequestOptions<T> = {
     request: () => Promise<T>;
     url: string;
+    requestIsIdempotent?: boolean;
 } & NetworkRetryBehaviour;
 /**
  * Checks if an error is a transient network error that is likely to recover with retries.

@isaacroldan isaacroldan changed the title Treat gateway 5xx responses as expected and retryable Stop reporting gateway errors as CLI crashes Aug 14, 2026
@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/cli @shopify/cli package issues labels Aug 14, 2026
@isaacroldan
isaacroldan marked this pull request as ready for review August 14, 2026 10:20
@isaacroldan
isaacroldan requested a review from a team as a code owner August 14, 2026 10:20
Assisted-By: devx/cfa7efa4-831b-4142-a418-5480cf27ac8c
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.

1 participant