Description
Cherry-picks commit 2e484c9 from closed PR #23568 so the CUS-199 follow-up optimization for GOOGLEDRIVE_UPLOAD_FROM_URL can land on master.
This is an incremental optimization on top of the merged base PR #23536 (which switched the action from full-file multipart buffering to a Drive resumable upload). The follow-up tightens the common known-size (Content-Length) path:
- Uploads each known-size chunk to Drive as soon as it is read instead of reading one chunk ahead.
- Keeps the unknown-size path's one-chunk lookahead so the final
Content-Range can still name the resolved total.
- Adds tests pinning bounded chunk sizes,
Content-Range values, and the no-lookahead behavior for Content-Length sources.
Net effect: lower peak memory (one chunk instead of two) and faster time-to-first-byte for the common Content-Length path.
How did I test this PR
uv run pytest tests/test_apps/test_googledrive/test_upload_from_url.py -q ✅ — 11 passed in 1.34s
uv run --with ruff ruff --config config/ruff.toml check apps/googledrive/actions/upload_from_url.py tests/test_apps/test_googledrive/test_upload_from_url.py ✅ — all checks passed
uv run --with ruff ruff --config config/ruff.toml format --check apps/googledrive/actions/upload_from_url.py tests/test_apps/test_googledrive/test_upload_from_url.py ✅ — 2 files already formatted
make fmt + MYPY_DIFF_ONLY=1 nox -s chk ✅ — all green
- Codex review ✅ — 1 P2 finding (boundary-aligned EOF gap on the no-lookahead path) documented in a follow-up comment; not fixed here so the cherry-pick stays faithful to #23568.
E2E: GOOGLEDRIVE_UPLOAD_FROM_URL requires real Drive OAuth + an upload target, so it can only be exercised in prod. The underlying base PR #23536 has been running in prod since merge; CI tests + lint-and-type-checks (both green) cover the regression surface this change introduces.
Pre-existing CI failure: secrets-detection.yml fails on every Mercury PR (including the original #23568 and recent cortex/zen PRs) due to a workflow-file/secret-inheritance issue on master — not caused by this PR. ci_status.py's rollup doesn't see it; visible via gh api repos/ComposioHQ/mercury/actions/runs?workflow_id=225585440.
Cherry-pick of: 2e484c9a961c16af728142259677161b278a041e
Original (closed) PR: https://github.com/ComposioHQ/mercury/pull/23568
Triggered by: samvit@composio.dev | Source: mcp
Session: https://zen-api-production-4c98.up.railway.app/dashboard/#/chat/zen-3b5e181f25e4