You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(gmail): preserve attachments carried in message body data - #50621
Keep files Gmail already included in a message so reading, downloading and forwarding do not silently omit them.
What Changed
Recognize named inline-data parts, including empty files, and download their existing bytes without calling the external-attachment endpoint. Preserve external-attachment reads and existing size checks.
Why
Gmail may return attachment bytes directly in MessagePartBody.data without an attachmentId. Orca only lists parts with an attachmentId and therefore silently drops these files when reading or forwarding messages.
Production callers: readGmail exposes downloadable attachment references; downloadGmailAttachment serves CLI/RPC attachment downloads; composeForward and composeRevision retain existing message files through savedAttachments.
This changes attachment data delivered by existing CLI/RPC operations, with no graphical layout or interaction control change.
Same production input before
After
The exact base production readGmail returned only remote.txt and omitted inline.bin and empty.txt.
Actual message reads list all three attachments; downloads and composeForward preserve exact binary, empty and external attachment bytes in order. Unavailable body data remains excluded.
Testing
I manually tested these changes locally through the actual production entries below
Automated regression added for external data integrity
The added regression fails against the original production code and uses the real operation with only provider responses supplied
Read a Gmail message with three named parts: binary bytes in body.data without an attachmentId, an empty body.data attachment, and an external attachmentId. Invoke readGmail, downloadGmailAttachment and composeForward. All three files should remain present with their exact bytes and order; an unavailable part without data or an ID remains excluded.
node config/scripts/test-runtime/execution-policy/run-vitest.mjs run --config config/vitest.config.ts src/main/google/google-gmail-inline-attachments.test.ts --maxWorkers=2
Integrated inline-attachment, existing forwarding-budget and MIME regressions:3files/5tests passed.
Final integrated validation: 32 focused regression tests in 22 files passed, including the unchanged archive-write failure case that had timed out under earlier heavy concurrent checking. The Drive performance contract passed separately (1 file/1 test). Changed-code quality passed with zero new findings across 129 changed paths; final touched-file formatting and git diff --check passed. Node typechecking passed for 17,026 files and web typechecking for 16,094 files using the repository-supported Bun compiler with one worker. These are aggregate validation results for the prepared contributions, not per-PR test counts.
The required pnpm check:changed --base=9890ea181c0f9ae59fb82da64c4a6fbc0504a817 was attempted after the final edits. Its workspace-package build is blocked because this environment rejects the tsx CLI local IPC socket (listen EPERM). The default tsrs typechecker was also terminated with SIGKILL; the supported Bun typechecking route completed successfully. The complete gate/build is not claimed to pass and still requires CI.
Linux was exercised locally. No live Google account, graphical desktop, macOS, Windows or SSH execution is claimed. The provider-neutral code remains on the existing runtime paths.
Performance
Existing account/part validation and declared-size limit remain. Inline attachment bytes are already present in the full message response, so no additional external-attachment request is made. Remote attachment retrieval is unchanged. Recognizing previously omitted files also includes them in the existing aggregate forward-size check. No MIME body-representation changes.
Risk
Level: Low
Previously omitted inline files are now included in downloads and forwarded drafts, so the existing aggregate size check may reject a draft that was previously incomplete. Account validation, external attachment retrieval and declared-size checks remain. No MIME text-representation change is included. A revert restores prior attachment detection; already saved files or sent messages are not altered.
AI Disclosure
Core contribution owner: @Afloat16. Required tooling disclosure: GPT-6 Astra Pro was used for implementation and review.
Review
Reviewed the actual operation, exact-base failure, normal controls, account/target identity, payload limits and cleanup. No new dependency, polling loop or RPC endpoint is introduced.
Agent skill upstream boundary
Not applicable: no upstream skill-installer material is copied or mechanically translated.
No actionable comments were generated in the recent review.
Walkthrough
Gmail attachment discovery now includes named message parts with inline data, including empty data. Attachment downloads use inline data when the part has no attachment ID. A new test checks inline, empty, remote, and unavailable parts, including their presence in reads and forwarded drafts.
Severity of issue fixed: Medium
Merge Risk: Minimal · up to 1b72a
Gmail attachments whose bytes are already in the message body, including empty files, now appear in reads and forwards and can be downloaded. The change is small, is covered by a focused test, and shows no merge-blocking risk.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(gmail): preserve attachments carried in message body data" matches the main change: named Gmail message parts whose bytes sit in body.data (including empty files) are now recognized and…
Description check
The description follows the repository template and covers the required sections. It has an ELI5, a What Changed section, a Why section with production callers, a linked issue (Fixes #50620), Visual P…
Linked Issues check
Directly linked issue #50620 requires that Gmail attachments whose bytes sit in body.data without an attachmentId stay visible in readGmail, downloadGmailAttachment, and composeForward. An unavailable…
Out of Scope Changes check
The changed areas match the linked issue. The changes are in src/main/google/google-gmail-message.ts (attachmentsOf detection), src/main/google/google-gmail-read.ts (inline data handling in downloadGm…
Full details: Title check
Explanation
The title "fix(gmail): preserve attachments carried in message body data" matches the main change: named Gmail message parts whose bytes sit in body.data (including empty files) are now recognized and kept in reads, downloads, and forwards. It is concise, specific, and follows a conventional commit style.
Full details: Description check
Explanation
The description follows the repository template and covers the required sections. It has an ELI5, a What Changed section, a Why section with production callers, a linked issue (Fixes #50620), Visual Proof marked N/A with a reason, Testing with the regression command and results, a Performance line, a Risk section with level and rollback, AI Disclosure, and the checklist. Testing is detailed and explains what could not be verified (full pnpm gate, live Google account, macOS, Windows, SSH). Minor gaps: the Performance section does not state a measured figure, and the Risk section does not name the platforms affected beyond Linux. These gaps are not critical.
Full details: Linked Issues check
Explanation
Directly linked issue #50620 requires that Gmail attachments whose bytes sit in body.data without an attachmentId stay visible in readGmail, downloadGmailAttachment, and composeForward. An unavailable part with neither data nor an ID must stay excluded.
Code at the reviewed head (src/main/google/google-gmail-message.ts): attachmentsOf now accepts a named part with a partId and a body when body.attachmentId is set or body.data !== undefined. An empty string counts as present. This fixes the listing that dropped inline.bin and empty.txt. Parts without a filename, or without body data or an attachmentId, remain excluded.
Code at the reviewed head (src/main/google/google-gmail-read.ts): readGmail uses attachmentsOf, so the inline and empty files now appear in the read view. downloadGmailAttachment resolves the part by ref. It calls the attachments endpoint only when body.attachmentId exists. Otherwise it decodes body.data (base64url to base64). It still rejects parts with no content source and keeps the TOOL_DOWNLOAD_MAX_BYTES check.
The PR reports a regression test (src/main/google/google-gmail-inline-attachments.test.ts) that covers readGmail, downloadGmailAttachment, and composeForward with exact bytes and order. I did not run this test. I did not inspect the composeForward or savedAttachments path directly, because the diff blobs were unavailable. Its behavior rests on the PR report and the stated reuse of attachmentsOf.
Full details: Out of Scope Changes check
Explanation
The changed areas match the linked issue. The changes are in src/main/google/google-gmail-message.ts (attachmentsOf detection), src/main/google/google-gmail-read.ts (inline data handling in downloadGmailAttachment), a regression test for issue #50620, and a test fixture that supplies the mocked account and HTTP client for that test. The PR description states that no MIME body-representation, RPC endpoint, or dependency change is included. The PR description also says the unrelated items #50497, #50413, and #48067 are not changed. I found no change outside the scope of issue #50620. Diff inspection was limited because the changed blobs were unavailable in the checkout, so this verdict relies on the head file contents and the PR summary.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Thanks @Afloat16 for finding and fixing this! We've landed your fix in #50765 (squashed onto current main with the inline-attachment test folded into the existing forward tests). Your authorship is preserved on the commit. Closing this one in favor of that PR.
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
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.
ELI5
Keep files Gmail already included in a message so reading, downloading and forwarding do not silently omit them.
What Changed
Recognize named inline-data parts, including empty files, and download their existing bytes without calling the external-attachment endpoint. Preserve external-attachment reads and existing size checks.
Why
Gmail may return attachment bytes directly in MessagePartBody.data without an attachmentId. Orca only lists parts with an attachmentId and therefore silently drops these files when reading or forwarding messages.
Production callers: readGmail exposes downloadable attachment references; downloadGmailAttachment serves CLI/RPC attachment downloads; composeForward and composeRevision retain existing message files through savedAttachments.
Linked Issue
Fixes #50620
Visual Proof
N/A
This changes attachment data delivered by existing CLI/RPC operations, with no graphical layout or interaction control change.
Testing
Read a Gmail message with three named parts: binary bytes in body.data without an attachmentId, an empty body.data attachment, and an external attachmentId. Invoke readGmail, downloadGmailAttachment and composeForward. All three files should remain present with their exact bytes and order; an unavailable part without data or an ID remains excluded.
Integrated inline-attachment, existing forwarding-budget and MIME regressions:3files/5tests passed.
Final integrated validation: 32 focused regression tests in 22 files passed, including the unchanged archive-write failure case that had timed out under earlier heavy concurrent checking. The Drive performance contract passed separately (1 file/1 test). Changed-code quality passed with zero new findings across 129 changed paths; final touched-file formatting and git diff --check passed. Node typechecking passed for 17,026 files and web typechecking for 16,094 files using the repository-supported Bun compiler with one worker. These are aggregate validation results for the prepared contributions, not per-PR test counts.
The required
pnpm check:changed --base=9890ea181c0f9ae59fb82da64c4a6fbc0504a817was attempted after the final edits. Its workspace-package build is blocked because this environment rejects the tsx CLI local IPC socket (listen EPERM). The default tsrs typechecker was also terminated with SIGKILL; the supported Bun typechecking route completed successfully. The complete gate/build is not claimed to pass and still requires CI.Linux was exercised locally. No live Google account, graphical desktop, macOS, Windows or SSH execution is claimed. The provider-neutral code remains on the existing runtime paths.
Performance
Existing account/part validation and declared-size limit remain. Inline attachment bytes are already present in the full message response, so no additional external-attachment request is made. Remote attachment retrieval is unchanged. Recognizing previously omitted files also includes them in the existing aggregate forward-size check. No MIME body-representation changes.
Risk
Level: Low
Previously omitted inline files are now included in downloads and forwarded drafts, so the existing aggregate size check may reject a draft that was previously incomplete. Account validation, external attachment retrieval and declared-size checks remain. No MIME text-representation change is included. A revert restores prior attachment detection; already saved files or sent messages are not altered.
AI Disclosure
Core contribution owner: @Afloat16. Required tooling disclosure: GPT-6 Astra Pro was used for implementation and review.
Review
Reviewed the actual operation, exact-base failure, normal controls, account/target identity, payload limits and cleanup. No new dependency, polling loop or RPC endpoint is introduced.
Agent skill upstream boundary
Notes
Primary sources:
Related submissions checked for distinct scope:
Checklist