[5620] fix(api): classify plain ZIP attachments correctly - #5736
[5620] fix(api): classify plain ZIP attachments correctly#5736Bharani010 wants to merge 1 commit into
Conversation
|
@Bharani010 is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Disabled knowledge base sources:
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe attachment classifier now inspects ZIP contents to distinguish generic ZIP archives from DOCX files. Invalid archives retain their inspected ZIP type. Unit tests cover the new ZIP and DOCX classification cases. ChangesZIP media classification
Estimated code review effort: 2 (Simple) | ~10 minutes ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Thanks @Bharani010! This PR now meets the contribution requirements and has been reopened. A maintainer will review it soon. |
Summary
Uploading a plain ZIP through
/sessions/attachmentsstored it with the DOCX media type. ZIP and DOCX share the same container signature, and PureMagic selected the more specific Word type without checking whether the archive contained Word structures.Before:
After:
Demo
Changes
The attachment classifier now inspects ZIP entry names before accepting the DOCX classification. Archives containing the required Word OOXML structure remain DOCX; other valid ZIP containers use
application/zip.The classifier reads only archive metadata. It does not extract archive contents, and inspected bytes remain authoritative over the client-declared media type.
Tests / notes
ruff formatpassed.ruff check --fixpassed.git diff --checkpassed.link.exe). CI should run the targeted test under its Linux environment.AI assistance
Model used: OpenAI GPT-5 through Codex.
Session summary: Codex inspected issue #5620, the attachment classifier, existing unit coverage, and repository contribution conventions. We reproduced that the repository-pinned PureMagic 1.30 classifies both a plain ZIP and a DOCX-shaped archive as DOCX. Codex then helped implement a focused policy that distinguishes DOCX by its internal Word OOXML entries, falls back to
application/zipfor ordinary ZIP archives, and adds regression coverage for both formats, incorrect client declarations, and malformed archive metadata. I reviewed the resulting diff and validation results before submitting it.Closes #5620.