Add a folder-scoped Google Drive resource - #440
Open
ndisidore wants to merge 1 commit into
Open
Conversation
ndisidore
force-pushed
the
feat/gk-google-drive-folder
branch
from
September 3, 2026 22:56
24a03b3 to
7256fd6
Compare
Preview:
|
|
Confines the existing read-only GoogleDriveSession API to one selected folder's current descendant subtree, for both My Drive folders and ordinary subfolders inside a shared drive. A shared drive's own root stays with the Shared Drive resource. Drive v3 offers no folder corpus, no folder-scoped token, and no recursive ancestor predicate -- `'<id>' in parents` means direct children only -- so membership is proved in the gatekeeper. drive-folder-scope.ts walks each candidate's parent chain upward through freshly batched files.get metadata, level by level, admitting only acyclic same-domain chains of live folders that reach the root within Drive's 101-hop nesting limit, then re-reads every node on the surviving paths immediately before disclosure. Nothing is cached across the operation that proved it: a hierarchy change rotates no credential and bumps no cache generation. The grant identity is an internal `/_resource/folder/:folderId` path rather than the natural browser URL, because `/drive/folders/:driveId` is already the shared drive's permanent identity and its pattern leaves the query component wildcard -- a query-qualified variant would match both resources and make resource selection order-dependent. describe() still reports the natural URL for the UI. Folder-derived Doc and Sheet children now revalidate: DriveSessionCore .nativeRead() re-proves ancestry and the exact native MIME type before the provider is contacted, re-checks the proved chain before any approval, and discards the fetched value if either fails. Drive has no ancestry-plus-content transaction, so a move landing after that final check still returns; the next read denies, and the method says so. CursorPager's authorize() now takes `exhausted` and its page budget is maxProviderPagesPerCall: reaching the bound authorizes the empty nonterminal page and returns [] rather than throwing, so a folder cursor can filter a whole page without claiming there are no results. Only an exhausted cursor reaches the empty-search path, which now fences observer admission through ObserverTracker.prepareWithheld() -- a withheld read registers no tracked set, so addObserver would otherwise verify a candidate against nothing. The Drive observer denial no longer names a file ID.
ndisidore
force-pushed
the
feat/gk-google-drive-folder
branch
from
September 4, 2026 16:16
7256fd6 to
9ae99a3
Compare
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| try { | ||
| return JSON.parse(text); | ||
| } catch { | ||
| throw new Error(`Google Drive ${context} was not valid JSON (${text.length} bytes)`); |
There was a problem hiding this comment.
🟡 Malformed responses report incorrect sizes
For malformed non-ASCII JSON, text.length counts UTF-16 units instead of response bytes. The Drive error therefore reports the wrong body size.
Prompt for agents
The new parseDriveJson error labels text.length as a byte count, but JavaScript string length counts UTF-16 code units. Preserve the raw byte count while reading the response and batch part, or change the diagnostic to accurately describe a character/code-unit count. Account for both regular Drive responses and multipart batch bodies.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
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.
Adds a fourth Google Drive resource, scoped to one folder and everything currently
beneath it, read-only. It covers a folder in My Drive, including one someone else
shared with you, and an ordinary subfolder inside a shared drive; a shared drive's
own root stays with the existing Shared Drive resource. It requests the same three
read-only scopes as the account and exact-file resources rather than the wider
drive.readonlythat Shared Drive needs.Folder-derived Doc and Sheet sessions re-prove ancestry on every method call, not only
at open, so a file moved out of the subtree stops answering through a session that is
already open. Drive has no ancestry-plus-content transaction, so a move landing after
the final check still returns and the next read denies.