Repository navigation
fix(den): harden Google Workspace retrieval - #4260
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
reachjalil
force-pushed
the
perf/google-drive-end-to-end-latency
branch
from
August 31, 2026 22:21
7d43f21 to
f1f4569
Compare
reachjalil
force-pushed
the
perf/google-drive-end-to-end-latency
branch
from
August 31, 2026 22:52
f1f4569 to
7d73b7d
Compare
Contributor
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (7d73b7da59b03729c3a4307ecab70a3349136d5d). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
benjaminshafii
pushed a commit
that referenced
this pull request
Nov 3, 2026
* fix(den): read the text of PDFs in Google Drive The Drive read capability (GET /v1/capabilities/google-workspace/drive-file/:fileId) treated a PDF like any other binary file. Since #4260 lowered the inline binary limit from 10 MB to 64 KB, any PDF over 64 KB returned content: null with contentUnavailableReason "file_too_large" without being downloaded, so an agent reading an ordinary ~415 KB PDF got nothing and reported the file as too large. Smaller PDFs came back as base64 the model cannot read. Behind googleDrivePdfText (off), PDFs up to 10 MB are downloaded with alt=media and their text layer extracted with unpdf (pdf.js), page by page up to the existing 200,000-character text limit. A PDF with no text layer returns the new "no_extractable_text" reason. Other file types are unchanged. * fix(den): read Drive PDFs up to 50 MB in a bounded worker Raise the PDF text-extraction cap from 10 MB to 50 MB (a separate constant; the 64 KB inline limit for other binaries is unchanged) and make it safe on a shared API server: - readBytesWithin streams the download with the cap enforced while reading, refusing a declared size over the cap and cutting off a body that grows past it, and reads a declared size into one buffer. - Extraction runs in a worker thread (512 MB heap limit, buffer transferred, not copied). pdf.js parses synchronously, so on the request thread it stalled other requests and no timer could stop it; the worker is terminated at a 15 s deadline, returning extraction_timed_out. At most two run at once. - The loading task is destroyed after every read; pages stop at the 200,000-character limit. - Unavailable PDF reads carry contentUnavailableHint: with a shell, use createGoogleDriveDownloadLink and read the file locally. scripts/measure-pdf-text.ts generates large image-heavy PDFs in memory and records time, memory and event-loop stalls. Worst case measured at 50 MB: 0.55 s, 263 MB above the file, 2 ms stall.
This branch was successfully deployed
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.
Summary
drive.readonlyor fulldrivegrant for general Drive search and file read, returning the existing actionableneeds_connectionresponse before any provider call when scopes are selected-file-only, missing, or unknowndrive.fileremains valid only for the existing upload/share operations that support itallDrivescorpus with the required Shared Drive flags and avoid the unsupported full-textorderBycombinationIncident assessment
drive.filewas accepted for general Drive search and read.Scope
This updates only the existing Google Workspace connector and existing MCP search/execute serialization path. It does not add a Drive app, custom results interface, companion launch tool, React component, HTML entry point, shared app payload, build registration, workflow, public option, or public API.
Verification
pnpm --filter @openwork-ee/den-api exec tsc --noEmitpnpm --filter @openwork-ee/den-api exec bun test test/mcp-tool-content.test.ts test/google-workspace-capabilities.test.ts test/google-workspace-api.test.ts— 74 passed, 0 failed, 369 assertionspnpm evals:pr specs/google-workspace-connector-retrieval.test.ts— 1 passed, 0 failed, 0 skippeddrive.file, missing scopes, empty scopes, and scope URL lookalikes reject general search/read with zero provider callsdrive.readonlyand fulldrivecorpora=allDrives,supportsAllDrives=true, andincludeItemsFromAllDrives=true, with no incompatibleorderBy__proto__keys do not mutate object prototypesdevis cleanOperational follow-up
The organization administrator enables Read all Drive files, the affected member reconnects Google Workspace and grants Drive read access, support confirms the recorded scopes, and the same original file ID is retried. That live reconnect/retry is environment-dependent and separate from the code proof above.