fix: Google Drive picks of native Docs fail with "appears to be empty"#2310
Merged
Conversation
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>
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



What
Three bugs in
handleGoogleDrive.tsthat combined to break the new native-Doc export path shipped in #2309. Mirrors the workinghandleDropbox.tspattern.responseType: 'blob'responseType: 'arraybuffer'buffer: contents.databuffer: Buffer.from(contents.data)size: file.sizeBytessize: buffer.lengthWhy
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: 0for native Google Docs (they have no fixed byte size).getUploadValidationErrorchecksfile.size === 0and 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 thetext/htmlbody to a string, and the parser would have read garbage.Pre-existing binary Drive picks worked because picker
sizeBytesis 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.lengthis correct for all paths.Testing
handleGoogleDrive.test.ts(now 7 tests, was 5):sizeBytesnative Doc produces non-zero size + real Buffer on the downstream file.responseType: 'arraybuffer'is in the request config.Risks
Buffer.from(ArrayBuffer)is a safe wrap for any binary content — no regression risk for PDFs etc.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
Need help on this PR? Tag
@codesmithwith what you need.