clienterror

package
v8.0.60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package clienterror classifies upstream failures caused by the client request.

Index

Constants

View Source
const GeminiFilterBlockMessagePrefix = "This request was blocked by Gemini's filters."

GeminiFilterBlockMessagePrefix is the leading text of Gemini's mid-stream content filter block frame.

View Source
const GeminiFilterBlockPolicyURL = "https://policies.google.com/terms/generative-ai/use-policy"

GeminiFilterBlockPolicyURL is the policy URL embedded in Gemini's mid-stream content filter block frame.

View Source
const StatusClientClosedRequest = 499

StatusClientClosedRequest is the nginx-style status used when the client aborts the request before the proxy finishes (context.Canceled).

Variables

This section is empty.

Functions

func ClaudePolicyRefusalMessage added in v8.0.56

func ClaudePolicyRefusalMessage(payload []byte) (string, bool)

ClaudePolicyRefusalMessage inspects a Claude Messages JSON payload (either a non-stream message object or a streaming message_delta event) and returns the refusal explanation when stop_details indicates a policy/cyber refusal block.

func GeminiFilterBlockMessage added in v8.0.56

func GeminiFilterBlockMessage(payload []byte) (string, bool)

GeminiFilterBlockMessage inspects a raw Gemini / Antigravity JSON payload and returns the filter block message when the payload is an injected mid-stream Gemini content filter frame.

Upstream injects this frame inside an HTTP 200 SSE stream with only candidates[0].content.parts[0].text and without content.role, responseId, modelVersion, or usageMetadata.

func HTTPStatusFromError

func HTTPStatusFromError(err error) int

HTTPStatusFromError extracts an HTTP status from err. Explicit StatusCode() values win. Otherwise context.Canceled maps to 499 and context.DeadlineExceeded maps to 504. Returns 0 when unknown.

func HTTPStatusFromErrorOr

func HTTPStatusFromErrorOr(err error, fallback int) int

HTTPStatusFromErrorOr is like HTTPStatusFromError but returns fallback when the error does not carry a known status.

func IsClaudePolicyRefusalError added in v8.0.56

func IsClaudePolicyRefusalError(err error) bool

IsClaudePolicyRefusalError reports whether err represents a Claude policy/cyber refusal block.

func IsClaudeThreadNotFound added in v8.0.14

func IsClaudeThreadNotFound(status int, err error) bool

IsClaudeThreadNotFound reports the Claude 404 response for a stale previous_message_id continuation from either a structured JSON response or a plain-text error message.

func IsClientCancellation

func IsClientCancellation(status int, err error) bool

IsClientCancellation reports whether an HTTP status code or error represents a client-initiated cancellation (HTTP 499 StatusClientClosedRequest or context.Canceled).

func IsCreditBalanceTooLow added in v8.0.50

func IsCreditBalanceTooLow(status int, err error) bool

IsCreditBalanceTooLow reports the Anthropic 400 response returned when a credential's API credit balance is exhausted.

func IsDevinRequestPermissionDenied added in v8.0.53

func IsDevinRequestPermissionDenied(status int, err error) bool

IsDevinRequestPermissionDenied reports whether a 403 error from Devin is deterministically caused by the request payload (such as the MCP tool configuration filter or the prompt content policy filter) rather than credential permissions.

func IsGeminiFilterBlockError added in v8.0.56

func IsGeminiFilterBlockError(err error) bool

IsGeminiFilterBlockError reports whether err carries a Gemini mid-stream content filter block message.

func IsItemNotPersisted

func IsItemNotPersisted(message string) bool

IsItemNotPersisted matches the upstream 404 raised when a request references a response item the upstream never stored because `store` was false. The upstream sends this as a plain-text message rather than a JSON body, so it cannot be recognized through the structured identifiers above.

The request can only succeed once the client rebuilds it without the stale reference, so it is a request fault: rotating credentials cannot help, and the client must be told rather than left to retry the same broken input.

func IsRequestFault

func IsRequestFault(status int, err error) bool

IsRequestFault reports whether an upstream failure is caused by the request and therefore must not rotate or penalize credentials.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL