fix: stop reporting rejected chat files as server errors
Merged
GI
5d ago+269+269+012345678901234567890123456789-1-1-0123456789
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:150raisesProviderRejectedChatFileErrorwhen the provider returns a 4xx (openai.BadRequestError) on a chat-file completion.search_files_toolcaught that typed rejection in its generic handler and logged it withexc_info=True, so Cloud Error Reporting grouped an unreadable attachment as a server fault. - Fix: catch
ProviderRejectedChatFileErrorinsearch_files_tool, log a warning with the cause type and status only (no traceback), and returnThe 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