Treat audio validation failures as non-retryable input errors (#58434)

## What changed

Map audio size, data, format, and sample-rate validation failures to `InvalidAudioInput` for HTTP 400 responses and streamed errors. Preserve the provider's message, falling back to `Invalid audio input.` when it is absent or blank.

Classify these errors as non-retryable and expose them as `BadRequest`. Redact their messages in doctor diagnostics and group them as invalid requests in telemetry.

## Testing

Add coverage for all six audio validation codes across HTTP errors, streamed `error` events, and `response.failed` events, checking error classification, message preservation, and the absence of retries. Extend doctor diagnostic redaction coverage for `InvalidAudioInput`.

GitOrigin-RevId: 0a59964bcabd83997bdb32fc9318a5482dac33b0
This commit is contained in:
Hung
2026-10-30 21:01:23 +00:00
committed by copyberry
parent 2546265e3e
commit 5a7353f040
8 changed files with 80 additions and 5 deletions
+5
View File
@@ -2481,6 +2481,9 @@ fn websocket_error_detail(err: &ApiError) -> String {
ApiError::InvalidRequest { .. } => {
"handshake error: invalid request: [redacted]".to_string()
}
ApiError::InvalidAudioInput { .. } => {
"handshake error: invalid audio input: [redacted]".to_string()
}
ApiError::ModelNotFound { .. } => {
"handshake error: model not found: [redacted]".to_string()
}
@@ -3317,6 +3320,7 @@ mod tests {
},
ApiError::RateLimit(message()),
ApiError::InvalidRequest { message: message() },
ApiError::InvalidAudioInput { message: message() },
ApiError::ModelNotFound {
message: message(),
status: Some(http::StatusCode::NOT_FOUND),
@@ -3344,6 +3348,7 @@ mod tests {
"handshake error: rate limit exceeded: [redacted]",
"handshake error: rate limit: [redacted]",
"handshake error: invalid request: [redacted]",
"handshake error: invalid audio input: [redacted]",
"handshake error: model not found: [redacted]",
"handshake error: invalid prompt: [redacted]",
"handshake error: cyber policy: [redacted]",