Skip to content

fix(google-docs): request mimeType when creating docs so the Drive response parses - #52346

Merged
nwparker merged 1 commit into
mainfrom
bugbash/pr-52335
Nov 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
bugbash/pr-52335

Conversation

@nwparker

@nwparker nwparker commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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".

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 0

What Changed

  • Before: orca docs create created the document in Drive, then reported "Google answered in a shape Orca does not understand." A retry made a second copy.
  • After: the command returns the created doc's id, title and link.
  • Mechanism: createDoc (src/main/google/google-docs.ts) sent the multipart upload with fields=id,name,webViewLink and parsed the answer with the shared DriveFileSchema, which requires mimeType. Drive partial responses only include the requested fields, so safeParse failed, the reader returned null, and the client threw after the write had landed. The mask is now id,name,mimeType,webViewLink. The schema stays strict.
  • New regression test src/main/google/google-docs-create.test.ts: goes through the public createDoc entry point with a fake Google API that returns only the fields named in the request's fields parameter (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 DriveFileSchema parse (getDriveFile, drive search, and the three writes in google-drive.ts). They all use FILE_FIELDS, which includes mimeType, so createDoc was the only mismatch. Switching createDoc to FILE_FIELDS would 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 create path. 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 with Unreadable creation response. An extra probe (folder by id plus askedBy, and a missing-webViewLink fallback) also failed on main with GoogleToolError after 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.ts passed 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. createDoc is 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. mimeType is 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_FIELDS so the mask can't drift from the schema.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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).
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues were found.

Summary

createDoc now requests mimeType, so Drive's response includes every field the existing reader requires.

  • Google Docs creation now returns the created document.

Reviews (2) · Last reviewed commit: "fix(google-docs): request mimeType when ..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Drive upload request for createDoc now includes mimeType with the existing fields. A Vitest test checks the returned account, ID, title, link, and "Created" status. It also checks that unexpected API calls and unreadable responses are rejected.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 2ae1f

This fix lets document creation succeed when Drive returns only the requested fields, which avoids a false failure and a possible duplicate document on retry. The change is small and I found no merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: createDoc now requests mimeType in the Drive fields mask so the response parses. It matches the diff (one-line field mask change in google-docs.ts plus a regression test). …
Description check Passed The description follows the repository template. It covers ELI5, What Changed, Why, a Linked Issue (Fixes #52333), Visual Proof marked N/A with a reason, Testing with the regression test and commands …
Linked Issues check Passed [#52333] Requires a successful orca docs create to return the created document's ID, title, link, and success result, while keeping shared schema validation. At head, createDoc in `src/main/google…
Out of Scope Changes check Passed The whole-PR diff could not be read: the inspection tool reported changed blobs missing from the checkout. The assessment therefore uses the head file contents and the PR summary. The summary lists tw…
Full details: Title check

Explanation

The title names the change: createDoc now requests mimeType in the Drive fields mask so the response parses. It matches the diff (one-line field mask change in google-docs.ts plus a regression test). Its scope is focused and it is specific.

Full details: Description check

Explanation

The description follows the repository template. It covers ELI5, What Changed, Why, a Linked Issue (Fixes #52333), Visual Proof marked N/A with a reason, Testing with the regression test and commands run, a Performance line, and a Risk section with level Low and a revert note. The Review and Notes sections are filled in. Some items remain open: the Checklist item for pnpm lint/typecheck/test/build is unchecked, and the manual testing box is unchecked. The AI Disclosure section is left empty, which the template allows for internal contributors. Overall the description is mostly complete.

Full details: Linked Issues check

Explanation

[#52333] Requires a successful orca docs create to return the created document's ID, title, link, and success result, while keeping shared schema validation. At head, createDoc in src/main/google/google-docs.ts sets the Drive fields parameter to id,name,mimeType,webViewLink and parses the response with parseGoogleJson(DriveFileSchema). DriveFileSchema requires mimeType, so the mask now returns it and the parse can succeed. The function returns id, title, link (falling back to docLink), and done: 'Created'. The regression test src/main/google/google-docs-create.test.ts calls the public createDoc entry point. Its fake send returns only the fields named in the request's fields parameter and runs the production reader. It asserts the expected account, id, title, link, and 'Created' result. The test covers the issue's reproduction. The PR description reports the test failed on the base and passed with the fix. I did not re-run tests. The duplicate-document risk is a caller retry concern, and the issue does not require code for it. No unmet coding requirement is found.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff could not be read: the inspection tool reported changed blobs missing from the checkout. The assessment therefore uses the head file contents and the PR summary. The summary lists two changed files: src/main/google/google-docs.ts (+1/-1) and the new test src/main/google/google-docs-create.test.ts (+38/-0). The head createDoc shows only the field mask change. The test directly supports the linked objective. The PR description states that DriveFileSchema stays strict and that no other file changes. No unrelated change is identified from the available evidence.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 576c49e3-ba12-44aa-a172-5e7a8b4f9b41
Commits

Reviewing files that changed from the base of the PR and between 71245dd and 2ae1f9d.

Files selected for processing: 2

  • src/main/google/google-docs-create.test.ts
  • src/main/google/google-docs.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@nwparker
nwparker merged commit 5cd254d into main Nov 29, 2026
55 checks passed
@nwparker
nwparker deleted the bugbash/pr-52335 branch November 29, 2026 07:20
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.

[Bug]: Successful Google Docs creation is reported as an unreadable response

2 participants