Skip to content

feat(gateway): add GatewayFailedDependencyError (424)#15859

Open
R-Taneja wants to merge 2 commits into
mainfrom
feat/gateway-failed-dependency-error
Open

feat(gateway): add GatewayFailedDependencyError (424)#15859
R-Taneja wants to merge 2 commits into
mainfrom
feat/gateway-failed-dependency-error

Conversation

@R-Taneja
Copy link
Copy Markdown
Contributor

@R-Taneja R-Taneja commented Jun 6, 2026

What

Adds a general-purpose GatewayFailedDependencyError and maps the Gateway failed_dependency error type (HTTP 424 Failed Dependency) to it.

Not provider-specific — any Gateway response where the request couldn't be fulfilled because a dependency wasn't available on the serving credentials/provider.

import { GatewayFailedDependencyError } from '@ai-sdk/gateway';

catch (error) {
  if (GatewayFailedDependencyError.isInstance(error)) {
    // error.statusCode === 424, error.type === 'failed_dependency'
  }
}

Why

Today a failed_dependency type hits the default case of createGatewayErrorFromResponse and becomes GatewayInternalServerError (type: 'internal_server_error'). The HTTP status (424) and isRetryable (false) are already preserved correctly — only the type is mislabeled as an internal server error. This adds the matching case so the type is accurate.

  • isRetryable === false (424 is outside the 408/409/429/≥500 retry set), so it won't be auto-retried by retryWithExponentialBackoff.
  • Follows the existing one-class-per-type pattern; only adds a case + class + exports, default untouched.

First consumer: the Gateway-side explicit-cache fallback refusal (vercel/ai-gateway#2177).

Tests

  • New case in create-gateway-error.test.ts (type, message, 424, isRetryable: false).
  • Full gateway suite green (429 node + 429 edge), type-check + lint clean, changeset included.

Map the Gateway `failed_dependency` error type (HTTP 424) to a dedicated,
general-purpose GatewayFailedDependencyError instead of letting it fall through
to GatewayInternalServerError (which mislabels the type as internal_server_error).
Status and isRetryable already flow through correctly; this fixes type fidelity.
424 is non-retryable (outside the 408/409/429/>=500 set).
@R-Taneja R-Taneja added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Admins only: add this label to a pull request in order to backport it to the prior version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants