fix: stop reporting rejected chat files as server errors

Merged
GI
5d ago
+269-1

Summary

  • GCP error group: {"source": "gcp", "service": "backend", "group": "chat_file.py:150 | utils.other.chat_file.ProviderRejectedChatFileError: The file could not be processed.", "count": 2, "id": "gcp:backend-chat-file-py-150-utils-other-chat-file-providerrejectedchatfileerror-the-file-could-not-be-processed-"}
  • Root cause: chat_file.py:150 raises ProviderRejectedChatFileError when the provider returns a 4xx (openai.BadRequestError) on a chat-file completion. search_files_tool caught that typed rejection in its generic handler and logged it with exc_info=True, so Cloud Error Reporting grouped an unreadable attachment as a server fault.
  • Fix: catch ProviderRejectedChatFileError in search_files_tool, log a warning with the cause type and status only (no traceback), and return The file could not be processed. to the agent.

Product invariants affected

none

Test plan

  • backend/.venv/bin/python -m py_compile utils/retrieval/tools/file_tools.py tests/unit/test_chat_file_completions.py tests/unit/test_file_tools_sanitization.py
  • backend/.venv/bin/python -m pytest tests/unit/test_chat_file_completions.py -q --tb=short — 7 passed, 8 warnings in 8.72s
  • backend/.venv/bin/python -m pytest tests/unit/test_file_tools_sanitization.py -q --tb=short — 4 passed in 0.07s

Failure-Class: none