Single Attachment Bug Fixes#472
Conversation
There was a problem hiding this comment.
The PR introduces two substantive issues: the reordering of onPrepareAttachment before the MIME-type validation in plugin.js is the more critical one — it breaks MIME validation for stream PUT requests because mimeType hasn't been derived from the filename yet at the time validateAttachmentMimeType runs. Additionally, the new filename-fetching block in finalizePrepareAttachment duplicates logic that already exists in resolveFilename, creating a maintenance risk.
PR Bot Information
Version: 1.26.11
- Correlation ID:
1b371dd1-c957-41f8-a37d-487d99c81d8e - Event Trigger:
pull_request.opened - LLM:
anthropic--claude-4.6-sonnet - File Content Strategy: Full file content
SummaryThe following content is AI-generated and provides a summary of the pull request: Fix Single Attachment Bugs: UI Facet Injection and MediaType Validation CrashBug Fix🐛 Resolves two bugs affecting inline (
Changes
GitHub Issues
PR Bot InformationVersion:
|
There was a problem hiding this comment.
The PR contains a real ordering bug: moving onPrepareAttachment before the MIME-type and size validations was meant to populate mimeType for inline stream PUTs, but validateAttachmentMimeType finds the inline prefix by searching req.data[${p}_content], which is always falsy when req.data is the raw binary body — causing the guard if (!validateAttachmentMimeType(req)) return to abort the upload entirely, a regression for all inline attachment stream PUTs. The other changes (the unfoldModel guard fix and the filename DB-fallback lookup) look correct.
PR Bot Information
Version: 1.26.14
- Correlation ID:
24bae380-76b2-11f1-9af1-dc60f6d0660c - File Content Strategy: Full file content
- LLM:
anthropic--claude-4.6-sonnet - Event Trigger:
pull_request.ready_for_review
| await onPrepareAttachment(req) | ||
| if (!validateAttachmentMimeType(req)) return |
There was a problem hiding this comment.
Logic Error: For stream PUT requests (when req.subject.ref.length > 1), req.data is the raw binary body, not an object with ${prefix}_content keys. validateAttachmentMimeType finds the inline prefix by checking req.data[${p}_content] — which is always falsy in this path — so it returns false, and the if (!validateAttachmentMimeType(req)) return guard then aborts the upload prematurely (a regression).
The original ordering called onPrepareAttachment after both validations, so this wasn't a problem before. In the stream PUT path, either the validation needs to be skipped when no content-bearing req.data key is present, or mimeType needs to be populated differently before validation runs.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
Addressing issues #470 and #471