Accept unknown Codex error variants in the app-server protocol (#49806)

## Why

New error variants should not prevent older clients from handling app-server errors.

## What changed

- Deserialize unknown `CodexErrorInfo` strings and objects as `Other` in Rust, while preserving known variants and the `"other"` serialization.
- Allow arbitrary strings and objects in the exported JSON schemas and TypeScript type.
- Update Python SDK generation and generated models to accept unknown error strings and object payloads.

## Testing

Add Rust tests for `"other"` round trips, unknown string and object fallbacks, known structured variants, and rejection of null, boolean, numeric, and array values.

GitOrigin-RevId: 40c17896019924b2ef7970ee2205ea0154d0d1b3
This commit is contained in:
Adam Perry @ OpenAI
2026-10-01 01:38:04 +00:00
committed by copyberry
parent e7798c9944
commit a5d56d8120
26 changed files with 303 additions and 69 deletions
@@ -538,7 +538,7 @@ class ClientInfo(BaseModel):
version: str
class CodexErrorInfoValue(Enum):
class CodexErrorInfoValue(str, Enum):
context_window_exceeded = "contextWindowExceeded"
session_budget_exceeded = "sessionBudgetExceeded"
usage_limit_exceeded = "usageLimitExceeded"
@@ -555,6 +555,15 @@ class CodexErrorInfoValue(Enum):
sandbox_error = "sandboxError"
other = "other"
@classmethod
def _missing_(cls, value: object) -> CodexErrorInfoValue | None:
if not isinstance(value, str):
return None
member = str.__new__(cls, value)
member._name_ = value
member._value_ = value
return member
class HttpConnectionFailed(BaseModel):
model_config = ConfigDict(
@@ -7669,6 +7678,7 @@ class CodexErrorInfo(
| ResponseStreamDisconnectedCodexErrorInfo
| ResponseTooManyFailedAttemptsCodexErrorInfo
| ActiveTurnNotSteerableCodexErrorInfo
| dict[str, Any]
]
):
model_config = ConfigDict(
@@ -7680,7 +7690,8 @@ class CodexErrorInfo(
| ResponseStreamConnectionFailedCodexErrorInfo
| ResponseStreamDisconnectedCodexErrorInfo
| ResponseTooManyFailedAttemptsCodexErrorInfo
| ActiveTurnNotSteerableCodexErrorInfo,
| ActiveTurnNotSteerableCodexErrorInfo
| dict[str, Any],
Field(
description="This translation layer make sure that we expose codex error code in camel case.\n\nWhen an upstream HTTP status is available (for example, from the Responses API or a provider), it is forwarded in `httpStatusCode` on the relevant `codexErrorInfo` variant."
),