claude-code - 💡(How to fix) Fix [BUG] Drive MCP `create_file` silently truncates binary uploads around 10K base64 chars [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#50358Fetched 2026-04-19 15:22:02
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1

The Drive MCP create_file tool silently truncates large binary uploads. A 12 KB multi-sheet xlsx (16,016 base64 chars) uploaded with mimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet arrives in Drive as 8,447 bytes — the first 5 of 13 zip entries intact, central directory chopped off entirely. Google Sheets then refuses to open it ("File could not open. Try refreshing the page."). The tool returns a successful response with a valid id and viewUrl — there's no error, no warning, no size field in the response that would let the caller detect the truncation.

Intermediate payload sizes also fail but with a different bogus error: a 7,223-byte xlsx (9,632 base64 chars, generated by Python base64.b64encode) is rejected outright with "The file content is not a valid base64 string." even though it's perfectly valid base64.

Error Message

The Drive MCP create_file tool silently truncates large binary uploads. A 12 KB multi-sheet xlsx (16,016 base64 chars) uploaded with mimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet arrives in Drive as 8,447 bytes — the first 5 of 13 zip entries intact, central directory chopped off entirely. Google Sheets then refuses to open it ("File could not open. Try refreshing the page."). The tool returns a successful response with a valid id and viewUrl — there's no error, no warning, no size field in the response that would let the caller detect the truncation. Intermediate payload sizes also fail but with a different bogus error: a 7,223-byte xlsx (9,632 base64 chars, generated by Python base64.b64encode) is rejected outright with "The file content is not a valid base64 string." even though it's perfectly valid base64.

  • The 9.6K-b64 "not a valid base64 string" error is actively misleading — it makes callers assume encoding problems when the encoding is fine.

Root Cause

The Drive MCP create_file tool silently truncates large binary uploads. A 12 KB multi-sheet xlsx (16,016 base64 chars) uploaded with mimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet arrives in Drive as 8,447 bytes — the first 5 of 13 zip entries intact, central directory chopped off entirely. Google Sheets then refuses to open it ("File could not open. Try refreshing the page."). The tool returns a successful response with a valid id and viewUrl — there's no error, no warning, no size field in the response that would let the caller detect the truncation.

Intermediate payload sizes also fail but with a different bogus error: a 7,223-byte xlsx (9,632 base64 chars, generated by Python base64.b64encode) is rejected outright with "The file content is not a valid base64 string." even though it's perfectly valid base64.

Fix Action

Fix / Workaround

Workaround (for anyone hitting this)

RAW_BUFFERClick to expand / collapse

[BUG] Drive MCP create_file silently truncates binary uploads around 10K base64 chars

Summary

The Drive MCP create_file tool silently truncates large binary uploads. A 12 KB multi-sheet xlsx (16,016 base64 chars) uploaded with mimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet arrives in Drive as 8,447 bytes — the first 5 of 13 zip entries intact, central directory chopped off entirely. Google Sheets then refuses to open it ("File could not open. Try refreshing the page."). The tool returns a successful response with a valid id and viewUrl — there's no error, no warning, no size field in the response that would let the caller detect the truncation.

Intermediate payload sizes also fail but with a different bogus error: a 7,223-byte xlsx (9,632 base64 chars, generated by Python base64.b64encode) is rejected outright with "The file content is not a valid base64 string." even though it's perfectly valid base64.

Repro

  1. Generate any multi-tab xlsx locally (~12 KB, e.g. 5 sheets with a few hundred cells total).
  2. Base64-encode the bytes → 16K-char string.
  3. Call create_file with mimeType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, the base64 content, and a parentId.
  4. Tool returns {id, title, viewUrl} — looks like success.
  5. get_file_metadata on the returned id reports fileSize: "8447" (the original was 12,012).
  6. Download the bytes back with download_file_content and diff against the local source: first 582 bytes match exactly, then the file just ends mid-deflate-stream inside xl/theme/theme1.xml.
  7. Opening in Google Sheets → "File could not open. Try refreshing the page." Same in Excel.

Size cliff (bounded experimentally)

Payload bytesBase64 charsBehaviour
~6,500~8,700✅ Uploads intact
7,2239,632❌ Rejected: "The file content is not a valid base64 string."
12,01216,016❌ Silently truncated to 8,447 B
8,024 (CSV, text/csv)10,700✅ Uploads intact, auto-converts to native Sheet

The text/csv conversion path is more lenient than the binary-blob path. The cliff for binary uploads is somewhere in 9.5K–11K base64 chars, with two different failure modes on either side.

Impact

  • Anyone uploading a real-world xlsx / pptx / pdf (or any multi-KB binary) via this tool hits the bug. These are the exact file types users most commonly generate in Cowork workflows.
  • Completely silent to the caller: only way to detect is to download the bytes back and inspect. In practice this means the LLM tells the user "here's your file" and the user reports back "I can't open it."
  • The 9.6K-b64 "not a valid base64 string" error is actively misleading — it makes callers assume encoding problems when the encoding is fine.

Suggested fixes

  1. Fix the underlying limit. A 12 KB binary upload is small. Whatever the real cap is, it should comfortably exceed ordinary files.
  2. If there's a hard limit, fail loudly with PayloadTooLargeError: content exceeds N bytes instead of silently truncating.
  3. Return fileSize / checksum in the create_file response so callers can client-side verify len(decoded_content) == response.fileSize.
  4. Document the cap in the tool description. "Max content size: N KB" in the JSONSchema would save a lot of wasted debugging.
  5. Consider resumable / chunked upload under the hood for non-trivial binary payloads — the Drive v3 API already supports this (uploadType=resumable).

Workaround (for anyone hitting this)

Pivot xlsx/multi-tab outputs to one CSV per tab, upload each with mimeType: "text/csv". The Drive MCP auto-converts text/csv to a native Google Sheet server-side. Trade-off is five Sheets instead of one workbook, but the uploads actually work.

Context

  • Hit this while building a personal skill that emits a 5-tab xlsx (tour-date overlap finder). Every single run was producing a corrupt Sheet in Drive; took an hour of byte-level diffing to realise the tool was lying about success.
  • Repro artifact ID (valid locally, corrupt in Drive): 1n6mVgT4Zz9BUlZaBP0V51pY8BBfRa2mh — happy to share binary dumps if it'd help triage.

extent analysis

TL;DR

The most likely fix for the silent truncation of binary uploads in the Drive MCP create_file tool is to increase the underlying limit or implement a resumable upload feature.

Guidance

  • Investigate the uploadType=resumable feature in the Drive v3 API to enable chunked uploads for large binary payloads.
  • Consider adding a fileSize or checksum field to the create_file response to allow callers to verify the integrity of the uploaded file.
  • If a hard limit exists, modify the tool to fail loudly with a PayloadTooLargeError instead of silently truncating the upload.
  • Document the maximum content size in the tool description to prevent similar issues in the future.
  • As a temporary workaround, pivot xlsx/multi-tab outputs to one CSV per tab and upload each with mimeType: "text/csv".

Example

No code snippet is provided as the issue is more related to the tool's behavior and API limitations.

Notes

The exact cause of the truncation is not specified, but it appears to be related to a limit in the create_file tool. The suggested fixes aim to address this limit or provide a way to work around it.

Recommendation

Apply the workaround of pivoting xlsx/multi-tab outputs to one CSV per tab and uploading each with mimeType: "text/csv" until a more permanent fix is implemented. This approach allows for successful uploads, albeit with the trade-off of multiple Sheets instead of a single workbook.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING