Skip to content

fix(gmail): bound attachment reads when forwarding drafts - #50598

Closed
Afloat16 wants to merge 1 commit into
stablyai:mainfrom
Afloat16:afloat16/orca50-20261127-gmail-forward-concurrency
Closed

Afloat16 wants to merge 1 commit into
stablyai:mainfrom
Afloat16:afloat16/orca50-20261127-gmail-forward-concurrency

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

ELI5

Forward messages with many attachments using Orca's existing request budget instead of launching every download together.

What Changed

Retrieve saved attachments through the existing inBatches helper and GMAIL_CALLS_AT_ONCE budget. Preserve attachment ordering and aggregate byte limits.

Why

Forwarding or revising a message launches every attachment retrieval simultaneously. This ignores Orca's existing Gmail request budget and can fail the entire draft on a concurrent-request429.

saveGmailDraft invokes composeForward and composeRevision, both using savedAttachments.

Linked Issue

Fixes #50596

Visual Proof

N/A — this backend attachment concurrency fix has no graphical layout change. The reproducible before/after behavior is recorded below.

Before/after data-level reproduction of the same input:

Before After
Forwarding12 small files fails at the modeled GoogleApi concurrency boundary. The same production composeForward entry succeeds with all attachments in order; a single attachment still has the original contents.

No graphical layout change is included. The evidence above is from the production operation; no desktop screenshot is claimed.

Testing

  • I manually tested these changes locally through the production-entry reproduction described above
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

External concurrency invariant

node config/scripts/test-runtime/execution-policy/run-vitest.mjs run --config config/vitest.config.ts src/main/google/google-gmail-forward-concurrency.test.ts

Locally exercised on Linux with Node 24.22.3. External API cases use protocol fixtures; no live provider account, graphical desktop, macOS, Windows or remote SSH execution is claimed.

Changed-code quality passed with zero findings. Node typecheck passed (17,005 files); web typecheck passed (16,094 files). The integrated regression run passed 51 tests in 30 files; the Drive performance contract passed separately. The final three test typing changes were rerun and passed. These are aggregate first-batch results, not per-PR test counts.

The required pnpm check:changed --base=9890ea181c0f9ae59fb82da64c4a6fbc0504a817 was attempted after final edits. It stopped in the workspace-package build because this environment rejects the tsx CLI's local IPC socket (listen EPERM). The full gate/build is therefore not claimed to pass; CI remains required. The process-host build entry executed successfully using node --import tsx --conditions=orca-source.

Performance

Low. At most the existing 10-request budget is spent per attachment batch. Number of reads and output bytes do not increase; many-file operations trade unrestricted parallelism for fewer quota refusals.

Risk

Level: Low

Low. At most the existing 10-request budget is spent per attachment batch. Number of reads and output bytes do not increase; many-file operations trade unrestricted parallelism for fewer quota refusals.

A plain revert restores the previous behavior; no schema migration is introduced.

AI Disclosure

Core contribution owner: @Afloat16. Required tooling disclosure: GPT-6 Astra Pro was used for implementation and review.

Review

Reviewed the production caller, baseline failure, ordinary controls, data integrity and additional work. No new shell commands, path grammar, remote protocol fields, polling or UI layout were introduced. SSH/remote, mobile and agent integrations retain their existing entry points.

Agent skill upstream boundary

  • Not applicable: this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments or documentation.

Notes

Primary references:

The user contribution history and targeted repository PR searches were checked for an existing equivalent change.

Checklist

  • This PR is small and focused
  • I explained what changed and why, including the mechanism and before/after result
  • I stated the risk and how to back it out
  • Before/after data evidence is included; no graphical layout change
  • Self-reviewed for correctness, security and performance
  • Cross-platform, SSH/remote and path/shortcut impact considered
  • Full lint/typecheck/test/build gate: component results and local IPC limitation are recorded above; CI still needs to cover the complete gate

@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Saved Gmail attachments are now downloaded through inBatches, using GMAIL_CALLS_AT_ONCE to limit concurrent requests. The existing attachment conversion and total-size check remain unchanged. A new test checks forwarding messages with 12 attachments and one attachment under a modeled 10-request concurrency limit.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 87099

Forwarding or revising drafts with many saved attachments now stays within the Gmail request budget while keeping attachment order. No actionable merge risk remains beyond running the usual CI checks.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(gmail): bound attachment reads when forwarding drafts" matches the main change. The raw summary and objectives say forwarding and revising drafts now fetch saved attachments in batches …
Description check Passed The description follows the template. It has ELI5, What Changed, Why, Linked Issue (Fixes #50596), Visual Proof (N/A with reason and data-level before/after), Testing, Performance, Risk with level and…
Linked Issues check Passed Issue #50596 requires that forwarding or revising a message with many saved attachments stay within GMAIL_CALLS_AT_ONCE (10). It requires retrieval through inBatches, attachment order preserved, and a…
Out of Scope Changes check Passed The whole-PR diff against the merge base 9890ea1 changes only src/main/google/google-gmail-draft-compose.ts (import of GMAIL_CALLS_AT_ONCE and inBatches; savedAttachme…
Full details: Title check

Explanation

The title "fix(gmail): bound attachment reads when forwarding drafts" matches the main change. The raw summary and objectives say forwarding and revising drafts now fetch saved attachments in batches limited by GMAIL_CALLS_AT_ONCE instead of unbounded concurrent downloads. The title names the Gmail scope and the forwarding behavior. It omits the revision path, which is a minor gap.

Full details: Description check

Explanation

The description follows the template. It has ELI5, What Changed, Why, Linked Issue (Fixes #50596), Visual Proof (N/A with reason and data-level before/after), Testing, Performance, Risk with level and revert path, AI Disclosure, Review, the upstream boundary checkbox, Notes, and Checklist. It is mostly complete. Gaps: the Performance and Risk paragraphs repeat the same text, the Why section gives no comparison with alternatives, the Testing section mixes a failing full gate with claimed results, and the Visual Proof before/after table is only a textual description rather than a switchable artifact. The template asks for the reason the chosen approach beats the alternatives, and that is missing.

Full details: Linked Issues check

Explanation

Issue #50596 requires that forwarding or revising a message with many saved attachments stay within GMAIL_CALLS_AT_ONCE (10). It requires retrieval through inBatches, attachment order preserved, and aggregate byte limits preserved. At the reviewed head, savedAttachments in src/main/google/google-gmail-draft-compose.ts retrieves files with inBatches(files, GMAIL_CALLS_AT_ONCE, ...) instead of an unbounded Promise.all. The inBatches helper in google-gmail-read.ts runs at most limit items at a time and appends results batch by batch, so output order matches input order. The total-size check before retrieval is unchanged. The same savedAttachments function serves composeForward and composeRevision, so both paths are covered. The PR adds src/main/google/google-gmail-forward-concurrency.test.ts, which the raw summary describes as a 12-attachment test against a mock API that rejects more than 10 concurrent requests. I did not read the test body, so its exact assertions are not independently verified. The implementation alone meets the stated coding requirements. The author's reported local runs were not re-executed here.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base 9890ea1 changes only src/main/google/google-gmail-draft-compose.ts (import of GMAIL_CALLS_AT_ONCE and inBatches; savedAttachments body rewritten to use inBatches) and adds the concurrency test file. Both changes connect directly to issue #50596. No unrelated source changes appear in the file listing or the summary. The PR description contains non-code claims about tooling, AI disclosure, and check results. These do not alter repository content and are not code scope issues.

  • 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9591900e-4d1b-49b6-b6af-9af44b61fb30
Commits

Reviewing files that changed from the base of the PR and between cbc710a and 870993b.

Files selected for processing: 2

  • src/main/google/google-gmail-draft-compose.ts
  • src/main/google/google-gmail-forward-concurrency.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @Afloat16 for this fix! We couldn't push to your branch, so it has been rebased onto the latest main and landed in #50671. Your authorship is preserved on the commit. Closing this one in favor of that PR.

@nwparker nwparker closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Forwarding many attachments exceeds Orca's Gmail request budget

2 participants