Files
sure/test/models/provider/openai
Ellion BlessanandClaude Sonnet 5 e69894adb9 fix(providers): capture API error response body in PDF processor span output (#2937)
* fix(providers): capture API error response body in PDF processor span output

Anthropic and OpenAI PDF processing errors only logged the exception
message, dropping the parsed response body that usually explains the
failure. Add safe_error_body to both providers' UsageRecorder concerns
and include it in the langfuse span output on failure, with tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013SYp89xEYfTkrxw8HcCUQ8

* fix(providers): allowlist PDF processor error fields sent to Langfuse

safe_error_body forwarded the entire upstream error body into the
langfuse span output. For custom OpenAI-compatible providers/proxies
(and the analogous Anthropic path), that body can echo request
content from the financial document being processed. Replace it with
safe_error_detail, which extracts only type/message/code/request_id
instead of the raw body.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013SYp89xEYfTkrxw8HcCUQ8

* test(openai): cover request_id extraction in PDF processor error_detail

The safe_error_detail request_id path (error.response_headers) had no
test coverage. Stub response_headers with x-request-id and assert it
appears in error_detail.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013SYp89xEYfTkrxw8HcCUQ8

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-20 14:59:08 +02:00
..