fix: categorize provider unsupported-MIME rejection as User#943
Open
cotovanu-cristian wants to merge 1 commit into
Open
fix: categorize provider unsupported-MIME rejection as User#943cotovanu-cristian wants to merge 1 commit into
cotovanu-cristian wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves agent-runtime error categorization by converting “unsupported attachment MIME type” failures (raised locally during provider request conversion) into structured AgentRuntimeErrors categorized as USER (AGENT_RUNTIME.FILE_ERROR) at the LLM invocation boundary.
Changes:
- Add
raise_for_unsupported_attachmenthelper to detectValueErrormessages containingUnsupported MIME type:in an exception__cause__chain and re-raise as aUSERFILE_ERROR. - Invoke the new helper from the
create_llm_nodeexception handling path alongside existing provider HTTP error mapping. - Add a test asserting the unsupported-MIME conversion failure is categorized as
USERwith codeAGENT_RUNTIME.FILE_ERROR.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/agent/react/test_llm_node.py |
Adds regression test asserting unsupported MIME type errors are mapped to USER / FILE_ERROR. |
src/uipath_langchain/agent/react/llm_node.py |
Hooks unsupported-attachment detection into the LLM invocation except block. |
src/uipath_langchain/agent/exceptions/attachments.py |
Introduces helper that detects “Unsupported MIME type” conversion failures and raises a structured AgentRuntimeError. |
Comment on lines
+35
to
+45
| if isinstance(cause, ValueError) and _UNSUPPORTED_MIME_MARKER in str(cause): | ||
| raise AgentRuntimeError( | ||
| code=AgentRuntimeErrorCode.FILE_ERROR, | ||
| title="Unsupported file attachment format.", | ||
| detail=( | ||
| "An attachment has a file type the model does not support. " | ||
| "Remove the attachment or convert it to a supported format." | ||
| ), | ||
| category=UiPathErrorCategory.USER, | ||
| ) from e | ||
| cause = cause.__cause__ |
Comment on lines
+372
to
+377
| self.mock_model.ainvoke = AsyncMock( | ||
| side_effect=ValueError( | ||
| "Unsupported MIME type: application/octet-stream." | ||
| " Please refer to the provider documentation for supported formats." | ||
| ) | ||
| ) |
58847d5 to
7b7e339
Compare
Format support for non-image attachments is delegated to the LLM/provider (#842) — do not reintroduce a client-side MIME allow-list. Instead, translate the provider's own 'Unsupported MIME type' ValueError (raised by langchain_aws Bedrock Converse during request conversion) into a User-categorized AgentRuntimeError(FILE_ERROR) at the model-invocation boundary in llm_node, matched across the exception chain. build_file_content_blocks_for keeps the #842 pass-through behavior (any non-image MIME -> file block). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7b7e339 to
11ceff9
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
A file attachment whose MIME type the model provider cannot read (e.g.
application/octet-streamto Bedrock Converse) caused the run to fail with an opaqueUnknowncategory. The underlyingValueError("Unsupported MIME type: ...")is raised bylangchain_awsduring Converse request conversion.Approach
Format support for non-image attachments is delegated to the LLM/provider (per #842, which deliberately removed the client-side file-type restriction). This PR does not reintroduce a MIME allow-list. Instead it reacts to the provider's actual verdict:
multimodal/invoke.py—build_file_content_blocks_forkeeps the feat: remove file type restriction for analyze files tool #842 pass-through (any non-image MIME → generic file block; no gating).exceptions/attachments.py—raise_for_unsupported_attachment(exc)walks the exception's__cause__/__context__chain for the provider's"Unsupported MIME type"marker and, if present, raises a User-categorizedAgentRuntimeError(FILE_ERROR)with an actionable message. No-op otherwise.react/llm_node.py— calls it in themodel.ainvokeexcept block (the model-invocation boundary), before the generic provider-HTTP handling.So we translate the provider's decision into a clean User error at the boundary, rather than pre-empting it with our own list.
Tests
test_exception_helpers.py— direct + cause-chain + no-op cases forraise_for_unsupported_attachment.test_utils.py— restored feat: remove file type restriction for analyze files tool #842 expectations: octet-stream and empty MIME pass through as file blocks (no raise at the source).tests/agentsuite: 920 passed; ruff + mypy clean.Sanitized: synthetic repros only; no internal/ticket/customer references.