mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Treat statusless bio and cyber policy errors as terminal (#62354)
## Why When the Responses API sends a policy rejection in an `error` event without an HTTP status, the SSE client can wait until its idle timeout to report the failure. ## What changed Recognize `bio_policy` and `cyber_policy` in the shared terminal error parser so both SSE and WebSocket clients surface the corresponding policy error. Preserve the provider's message and use a default when it is missing or blank. End the SSE stream as soon as the error arrives. ## Testing Add SSE tests for both error codes, including when the stream stays open, and WebSocket cases that verify both errors surface without a close handshake. GitOrigin-RevId: 1b46b6557a39a61a1bb10bdd0d8ede48ecd6fa13
This commit is contained in:
@@ -139,6 +139,16 @@ pub(crate) fn parse_terminal_provider_error(
|
||||
status,
|
||||
})
|
||||
}
|
||||
("cyber_policy", None) => Some(ApiError::CyberPolicy {
|
||||
message: message
|
||||
.unwrap_or("This request has been flagged for possible cybersecurity risk.")
|
||||
.to_owned(),
|
||||
}),
|
||||
("bio_policy", None) => Some(ApiError::BioPolicy {
|
||||
message: message
|
||||
.unwrap_or("This content was flagged for possible biological risk.")
|
||||
.to_owned(),
|
||||
}),
|
||||
// HTTP 403s retain their request ID and headers in the API bridge.
|
||||
("access_program_not_enabled", None) => Some(ApiError::AccessProgramNotEnabled {
|
||||
message: message
|
||||
|
||||
Reference in New Issue
Block a user