fix(agent): fail loud on non-UUID attachment output id as System error#941
Open
cotovanu-cristian wants to merge 1 commit into
Open
fix(agent): fail loud on non-UUID attachment output id as System error#941cotovanu-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 hardens the ReAct agent’s job-attachment extraction so malformed tool-output attachments (notably those with non-UUID ID values) no longer crash an agent run, and adds a regression test to ensure invalid attachments are skipped while valid ones are retained.
Changes:
- Update
get_job_attachmentsto catchpydantic.ValidationErrorper extracted attachment and skip invalid entries instead of raising. - Extend the function docstring to document the “skip invalid attachments” behavior.
- Add a test ensuring a non-UUID attachment ID in tool output is ignored and does not raise.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/uipath_langchain/agent/react/job_attachments.py |
Wraps per-attachment validation in try/except ValidationError so malformed attachments don’t abort the run. |
tests/agent/react/test_job_attachments.py |
Adds coverage verifying non-UUID attachment IDs are skipped and valid attachments still return. |
532f47e to
0323cb0
Compare
0323cb0 to
046a6f4
Compare
When a tool returned a job attachment whose ID is not a valid UUID, the loop in get_job_attachments called Attachment.model_validate with no error handling, so pydantic raised an uncaught ValidationError that crashed the agent run. An attachment with a non-UUID id is unrecoverable invalid data the SDK cannot safely proceed with, so it is now raised as a System-categorized AgentRuntimeError (INVALID_ATTACHMENT_ID) rather than swallowed. The output path deliberately does NOT mirror the input-side skip in replace_job_attachment_ids: invalid tool output must surface as a System failure, not be silently dropped. The error detail names the offending id without leaking any other attachment data. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
046a6f4 to
04f5f64
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
get_job_attachmentsinagent/react/job_attachments.pyvalidated everyextracted tool-output attachment with
Attachment.model_validate(...)insidea loop with no error handling.
Attachment.idis typeduuid.UUID, so when atool returned an attachment whose ID was not a valid UUID (e.g.
"att_x"),pydantic raised an uncaught
ValidationErrorthat propagated out and crashedthe entire agent run.
Fix
A tool returning an attachment with a non-UUID id is unrecoverable invalid data
the SDK cannot safely proceed with, so this is now a fail-loud System error,
not a skip.
get_job_attachmentsraises anAgentRuntimeErrorwith codeINVALID_ATTACHMENT_IDand categoryUiPathErrorCategory.SYSTEM(matching theexisting pattern in
analyze_files_tool.py).The output path deliberately does not mirror the input-side skip in
replace_job_attachment_ids: silently dropping invalid tool output would hide acorrectness problem, so it must surface as a System failure. The error detail
names the offending id and nothing else, so no other attachment data leaks.
Test
Replaced the prior skip-assertion test with
TestGetJobAttachments::test_raises_system_error_on_non_uuid_attachment_id,which feeds a tool-output payload containing an attachment with a non-UUID id
(
"att_x") and assertsget_job_attachmentsraises anAgentRuntimeErrorcategorized
SYSTEMwith codeINVALID_ATTACHMENT_IDand the offending id inthe detail. Confirmed failing-test-first (fails against the old skip behavior,
passes with the raise). Full local checks (
ruff format,ruff check,mypy,pytest) pass.🤖 Generated with Claude Code