Repository navigation
fix(google-docs): request mimeType when creating docs so the Drive response parses - #52346
Conversation
…sponse parses createDoc asked Drive for id,name,webViewLink but parsed the answer with DriveFileSchema, which requires mimeType. The partial response failed to parse, so the CLI reported a failure after the doc was already created, and a retry made a duplicate. Request mimeType too. Fixes #52333 Original fix by Afloat16 (#52335).
[Low impact] The PR appears safe to merge; no actionable issues were found. Summary
Reviews (2) · Last reviewed commit: "fix(google-docs): request mimeType when ..." · Reviewed by Greptile |
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
ELI5
When you asked Orca to create a Google Doc, Google made the doc but Orca said it failed. Orca asked Google for a short summary of the new doc and forgot to ask for one piece (the file type) that it then checks for, so it threw the answer away. Now it asks for that piece too, so creating a doc reports success. This also stops agents from making duplicate docs by retrying after a "failure".
What Changed
orca docs createcreated the document in Drive, then reported "Google answered in a shape Orca does not understand." A retry made a second copy.createDoc(src/main/google/google-docs.ts) sent the multipart upload withfields=id,name,webViewLinkand parsed the answer with the sharedDriveFileSchema, which requiresmimeType. Drive partial responses only include the requested fields, sosafeParsefailed, the reader returned null, and the client threw after the write had landed. The mask is nowid,name,mimeType,webViewLink. The schema stays strict.src/main/google/google-docs-create.test.ts: goes through the publiccreateDocentry point with a fake Google API that returns only the fields named in the request'sfieldsparameter (like Drive does) and runs the real production response reader.Why
This is the smallest correct fix: it keeps response validation strict and adds no network requests. I checked every other
DriveFileSchemaparse (getDriveFile, drive search, and the three writes ingoogle-drive.ts). They all useFILE_FIELDS, which includesmimeType, socreateDocwas the only mismatch. SwitchingcreateDoctoFILE_FIELDSwould also work, but it asks for more fields than this call needs.Linked Issue
Fixes #52333
Visual Proof
N/A. This fixes a main-process Google Drive response field mask used by the CLI/RPC
docs createpath. Nothing in the UI changes, and the behavior is covered by the regression test below.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Reproduced on macOS: with main's
google-docs.ts, the new test fails withUnreadable creation response. An extra probe (folder by id plusaskedBy, and a missing-webViewLinkfallback) also failed on main withGoogleToolErrorafter the POST was recorded, which confirms the "created but reported failed" path.With the fix:
vitest run src/main/google/google-docs-create.test.ts src/main/google/google-docs-comments.test.tspassed 5 of 5.The touched files pass oxlint, oxfmt --check, anti-slop oxlint, native code-quality oxlint and ast-grep with
--deny-warnings. The changed-code quality gate reported 0 new findings.No live Google account writes were made. The fixture models Drive's documented partial-response behavior.
Performance
None.
createDocis a cold path that runs once per user or agent request. There are no new requests, disk I/O, subprocesses, polling or renderer/store work, and nothing scales with the number of tabs or worktrees. The response is one scalar larger (188 vs 138 bytes). Parse micro-benchmark (JSON.parse plus zod safeParse, 100k iterations): old 0.352 us/parse with 0 of 100k succeeding, new 0.159 us/parse with 100k of 100k succeeding.Risk
Level: Low
The only change is which response fields the Docs create call asks for.
mimeTypeis a standard Drive File field that the other Drive file calls already request. Credentials, scopes, stored data and transport contracts don't change. A plain revert restores the old mask. It would not remove documents already created.Review
Reviewed for correctness, breakage and verification: all three passes approved with no blockers. Optional follow-up: share
FILE_FIELDSso the mask can't drift from the schema.Agent skill upstream boundary
Notes
Security, cross-platform, SSH/remote, mobile and backwards compatibility: there are no platform-specific paths or protocol changes, and agent callers get the existing success result shape.
Original fix by Afloat16 in #52335.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)