Skip to content

fix: Google Drive picks of native Docs fail with "appears to be empty"#2310

Merged
aalemayhu merged 1 commit into
mainfrom
fix/google-docs-empty-export
May 16, 2026
Merged

fix: Google Drive picks of native Docs fail with "appears to be empty"#2310
aalemayhu merged 1 commit into
mainfrom
fix/google-docs-empty-export

Conversation

@aalemayhu
Copy link
Copy Markdown
Contributor

@aalemayhu aalemayhu commented May 16, 2026

What

Three bugs in handleGoogleDrive.ts that combined to break the new native-Doc export path shipped in #2309. Mirrors the working handleDropbox.ts pattern.

Was Now
responseType: 'blob' responseType: 'arraybuffer'
buffer: contents.data buffer: Buffer.from(contents.data)
size: file.sizeBytes size: buffer.length

Why

A user picked a Google Doc named "2anki" after #2309 deployed. The server returned 400 with "2anki.html" appears to be empty. Please re-export your file and try again.

Root cause: the picker reports sizeBytes: 0 for native Google Docs (they have no fixed byte size). getUploadValidationError checks file.size === 0 and rejects before the parser sees the body. Even if size had been right, responseType: 'blob' is not valid in Node axios — it would have coerced the text/html body to a string, and the parser would have read garbage.

Pre-existing binary Drive picks worked because picker sizeBytes is non-zero for binary files. The 'blob' typo silently worked-enough for binary content too.

How

Match the Dropbox pattern exactly. Buffer.from(arrayBuffer) produces a real Node Buffer regardless of response Content-Type; buffer.length is correct for all paths.

Testing

  • handleGoogleDrive.test.ts (now 7 tests, was 5):
    • New: zero-sizeBytes native Doc produces non-zero size + real Buffer on the downstream file.
    • New: asserts responseType: 'arraybuffer' is in the request config.
    • Existing 5 tests still pass with no edits.

Risks

Goal alignment

Simpler/faster/more beautiful: yes — the "appears to be empty" error was the opposite of "drop something in, get a clean deck back". Toward scale: yes — Google Docs is the largest pool of cloud-native notes after PDFs.

🤖 Generated with Claude Code


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Three bugs in handleGoogleDrive vs. the working handleDropbox pattern:

1. responseType: 'blob' is not a valid axios responseType in Node. For
   text/html responses (the new native-Doc export path), axios coerced the
   body to a string and the downstream parser saw garbage.

2. buffer: contents.data forwarded whatever axios returned (string, raw
   ArrayBuffer, etc). Multer's downstream file shape needs a Node Buffer.

3. size: file.sizeBytes — the picker reports sizeBytes: 0 for native
   Google Docs because Docs have no fixed byte size. getUploadValidationError
   rejects size === 0 as "appears to be empty" before the parser ever
   reads the body.

Fix mirrors handleDropbox.ts exactly: responseType: 'arraybuffer',
buffer = Buffer.from(contents.data), size = buffer.length. Two regression
tests assert (a) zero-sizeBytes native Docs produce a non-zero size on
the downstream file, and (b) responseType: 'arraybuffer' is in the request
config so HTML/CSV bodies aren't string-coerced.

No changelog entry — the existing "Google Docs, Sheets, and Slides from
your Drive turn straight into decks" line from #2309 becomes accurate
once this lands. A duplicate fix entry on the same day would read as
confused noise.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@aalemayhu aalemayhu merged commit f2339f2 into main May 16, 2026
5 checks passed
@aalemayhu aalemayhu deleted the fix/google-docs-empty-export branch May 16, 2026 12:20
@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant