fix(sdk): tag raising S3 PUT failures with the s3_upload step#432
Merged
Conversation
AttachmentService promised every step surfaces as AttachmentUploadError carrying step, but the S3 put call was not wrapped: an httpx transport error or the uploader's host-allowlist ValueError bubbled bare, so the step-aware envelope degraded to a generic untagged error for exactly the network / tampered-URL failures where the stage tag matters most. The put call is now wrapped and re-raised as AttachmentUploadError(step="s3_upload") from the cause, keeping the attachment and knowledge-base document upload pipelines on one contract. Existing HTTP >= 400 tagging is unchanged. Closes #430
adriannoes
approved these changes
Jul 18, 2026
adriannoes
left a comment
Collaborator
There was a problem hiding this comment.
Summary
Surgical fix that closes #430: raising S3 PUT failures now surface as AttachmentUploadError with step="s3_upload", matching the KnowledgeBaseService wrap. Reviewed with checkout+tests; CI lint and test are green on the tip.
What worked well
- Mirrors the KB put wrap from #428 so attachment and knowledge-base uploads stay on one contract.
- Unit test asserts step, message fragment, and
__cause__; it fails if the wrap is removed. - Leaves the existing HTTP >= 400 tagging path untouched; no MCP/CLI surface churn needed.
Review path
- Checked out the PR tip, ran attachment_service unit tests (24 passed) and ruff on touched files; CI green.
- Callers (facade, MCP tools, CLI) already catch
AttachmentUploadErrorand benefit from the step tag. - Coverage polish (allowlist
ValueErrorin the service unit test) matches the intentional KB twin gap and was verified manually withHttpxS3Uploader; not a merge gate.
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.
Motivation
AttachmentService's docstring promises every step surfaces asAttachmentUploadErrorcarryingstep, but the S3putcall was not wrapped: an httpx transport error or the uploader's host-allowlistValueErrorbubbled bare instead of being taggedstep="s3_upload". Only HTTP >= 400 results from a completed PUT were tagged, so the step-aware error envelope silently degraded to a generic untagged error for exactly the network / tampered-URL failures where the stage tag is most useful.Outcome
Transport errors and host-allowlist rejections from the S3 PUT now raise
AttachmentUploadError(step="s3_upload")from the cause, keeping the attachment and knowledge-base document upload pipelines on one contract. Existing HTTP >= 400 tagging is unchanged.Closes #430