Skip to content

Add exception type to error responses in chat and completion endpoints#67

Merged
adambalogh merged 1 commit intomainfrom
claude/fix-tee-payment-error-gMSHh
May 5, 2026
Merged

Add exception type to error responses in chat and completion endpoints#67
adambalogh merged 1 commit intomainfrom
claude/fix-tee-payment-error-gMSHh

Conversation

@adambalogh
Copy link
Copy Markdown
Contributor

@adambalogh adambalogh commented May 5, 2026

Summary

Enhanced error responses across chat and completion endpoints to include the exception type, improving debugging and error handling visibility.

Key Changes

  • Chat Controller (_create_non_streaming_response): Added exception_type field to non-streaming error responses
  • Chat Controller (_create_streaming_response): Added exception_type field to streaming error responses and stream setup error responses
  • Completions Controller (create_completion): Added exception_type field to completion error responses

Implementation Details

  • All error responses now include exception_type: type(e).__name__ alongside the existing error message
  • This change applies to three error handling paths:
    1. Non-streaming chat completions
    2. Streaming chat completions (both stream generation and setup phases)
    3. Text completions
  • The exception type is extracted using Python's built-in type(e).__name__ to provide the class name of the caught exception
  • Logging behavior remains unchanged; only the response payload is enhanced

Returning only "Request processing failed" makes debugging in the TEE
nearly impossible since stack traces never leave the enclave. Including
the exception class name (e.g. ValueError, APIStatusError) is safe — class
names don't carry secrets — and is enough to distinguish missing-key
errors from upstream provider rejections without further deploy cycles.

https://claude.ai/code/session_01GGxcgU3UpPto6cq2AgEjkL
@adambalogh adambalogh merged commit 85033da into main May 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants