{"record":{"id":"b79085180006daf6","repo":"earendil-works/pi","slug":"codex-error-message-code-json-stringify-e","errorCode":null,"errorMessage":"Codex error: ${message || code || JSON.stringify(event)}","messagePattern":"Codex error: (.+?)","errorType":"exception","errorClass":"CodexApiError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/api/openai-codex-responses.ts","lineNumber":727,"sourceCode":"\t\t\ttypeof event.message === \"string\"\n\t\t\t\t? event.message\n\t\t\t\t: typeof nested?.message === \"string\"\n\t\t\t\t\t? nested.message\n\t\t\t\t\t: undefined,\n\t};\n}\n\nasync function* mapCodexEvents(\n\tevents: AsyncIterable<Record<string, unknown>>,\n\toutput: AssistantMessage,\n): AsyncGenerator<ResponseStreamEvent> {\n\tfor await (const event of events) {\n\t\tconst type = typeof event.type === \"string\" ? event.type : undefined;\n\t\tif (!type) continue;\n\n\t\tif (type === \"error\") {\n\t\t\tconst { code, message } = extractCodexEventError(event);\n\t\t\tthrow new CodexApiError(`Codex error: ${message || code || JSON.stringify(event)}`, {\n\t\t\t\tcode,\n\t\t\t\tpayload: event,\n\t\t\t});\n\t\t}\n\n\t\tif (type === \"response.failed\") {\n\t\t\tconst response = (event as { response?: { error?: { code?: string; message?: string } } }).response;\n\t\t\tconst code = response?.error?.code;\n\t\t\tconst message = response?.error?.message;\n\t\t\tthrow new CodexApiError(message || \"Codex response failed\", { code, payload: event });\n\t\t}\n\n\t\tif (type === \"response.done\" || type === \"response.completed\" || type === \"response.incomplete\") {\n\t\t\tconst response = (event as { response?: { status?: unknown; end_turn?: unknown } }).response;\n\t\t\tif (typeof response?.end_turn === \"boolean\") {\n\t\t\t\toutput.endTurn = response.end_turn;\n\t\t\t}\n\t\t\tconst normalizedResponse = response","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/ai/src/api/openai-codex-responses.ts#L709-L745","documentation":"Error \"Codex error: ${message || code || JSON.stringify(event)}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/ai/src/api/openai-codex-responses.ts:727 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Handle the Codex error event message or code in the payload; retry if transient."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}