fix: keep nested attachment and injected-option gateway rejections classified

Merged
GI
4d ago
+81-2

Summary

Follow-up to #21316 (merged as 80788c026f): two review findings on the gateway-normalized 400 classifier landed after the merge and are addressed here.

  1. Nested attachment rejections collapsed to invalid_messages (thread [PRRT_kwDOLkKqys6r4_Vf]): the gateway's _provider_rejection() roots messages[0].content[1].file.file_id to messages, so an unreadable/stale user file took the error-level branch in search_files_tool and re-entered Cloud Error Reporting as a server fault — the exact incident #21316 fixed. The gateway now preserves a bounded attachment-specific classification (invalid_attachment / unsupported_attachment) for allowlisted attachment param suffixes, and the soft path honors it.
  2. Gateway-injected option rejections downgraded (thread [PRRT_kwDOLkKqys6r4_Vs]): the gateway injects reasoning_effort: medium on the file-chat lanes (llm_gateway/config/generated_route_overrides.yaml), so invalid/unsupported_reasoning_effort is a gateway-config fault, not a bad file. Those members join the request-shape set and stay error-level.

Both changes stay inside the closed, allowlisted ProviderRejection classifier — no upstream body strings cross the wire.

Product invariants affected

none

Test plan

  • backend/.venv/bin/python -m pytest tests/unit/test_chat_file_completions.py tests/unit/test_llm_gateway_openai_provider.py -q — 48 passed
  • backend/.venv/bin/python -m pytest tests/unit/test_llm_gateway_openai_compatible.py -q — 36 passed
  • backend/.venv/bin/python -m pytest tests/unit/test_llm_gateway_metrics.py -q — 25 passed
  • backend/.venv/bin/python -m pytest tests/unit/test_file_tools_sanitization.py -q — 4 passed

Failure-Class: none