mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
Classify streaming rate-limit errors (#40931)
## What changed - Classify `response.failed` events with the `rate_limit_exceeded` code as a distinct retryable error while preserving any parsed retry delay. - Expose the error as `rateLimitExceeded` through the core protocol and app-server schemas after stream retries are exhausted. - Preserve the upstream message for TUI display while keeping it out of telemetry summaries. ## Testing - Cover SSE classification, retry metadata, protocol conversion and serialization, exhausted stream retries, telemetry redaction, and TUI rendering. GitOrigin-RevId: 02dab4d3477dcd7653a58c49c4bd38687a616579
This commit is contained in:
@@ -80,6 +80,7 @@ pub fn telemetry_api_error_message(error: &ApiError) -> String {
|
||||
ApiError::QuotaExceeded => "quota exceeded".to_string(),
|
||||
ApiError::UsageNotIncluded => "usage not included".to_string(),
|
||||
ApiError::Retryable { .. } => "retryable error".to_string(),
|
||||
ApiError::RateLimitExceeded { .. } => "rate limit exceeded".to_string(),
|
||||
ApiError::RateLimit(_) => "rate limit".to_string(),
|
||||
ApiError::InvalidRequest { .. } => "invalid request".to_string(),
|
||||
ApiError::CyberPolicy { .. } => "cyber policy".to_string(),
|
||||
@@ -134,7 +135,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn telemetry_error_messages_omit_http_bodies() {
|
||||
fn telemetry_error_messages_omit_upstream_bodies() {
|
||||
let transport = TransportError::Http {
|
||||
status: StatusCode::UNAUTHORIZED,
|
||||
url: Some("https://chatgpt.com/backend-api/codex/responses".to_string()),
|
||||
@@ -147,6 +148,13 @@ mod tests {
|
||||
telemetry_api_error_message(&ApiError::Transport(transport)),
|
||||
"http 401"
|
||||
);
|
||||
assert_eq!(
|
||||
telemetry_api_error_message(&ApiError::RateLimitExceeded {
|
||||
message: "private upstream diagnostic".to_string(),
|
||||
delay: Some(std::time::Duration::from_secs(1)),
|
||||
}),
|
||||
"rate limit exceeded"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user