Skip to content

fix(google-workspace): surface Shared Drive docs in Drive search via corpora#59

Open
xBalbinus wants to merge 1 commit into
mainfrom
fix/drive-search-shared-drives
Open

fix(google-workspace): surface Shared Drive docs in Drive search via corpora#59
xBalbinus wants to merge 1 commit into
mainfrom
fix/drive-search-shared-drives

Conversation

@xBalbinus

Copy link
Copy Markdown

Problem

Google Drive search misses certain docs — specifically anything that lives in a Shared Drive (Team Drive). Personal and directly-shared docs return fine; team/project/company docs in Shared Drives silently never appear.

Root cause (it's the corpus, not the OAuth scope)

Every Drive list/search defaults to corpora='user' (drive-actions.ts). Per Google's files.list spec, the 'user' corpus is "files owned by or shared to the user" and excludes files resident in a Shared Drive. The supportsAllDrives + includeItemsFromAllDrives=true flags we already send don't help — they're capability flags, not corpus-wideners. To reach shared drives you must use corpora='allDrives'.

The integration already requests the full https://www.googleapis.com/auth/drive scope, so the token can see these docs — the query just never asks for them. The OAuth-scope theory is a red herring here.

What this PR does (conservative — no default behavior change)

This is the low-risk path: it does not change the default corpus org-wide. Instead it makes allDrives reliable and discoverable:

  • Clarify the tool descriptions + google-drive skill so the agent knows 'user' excludes Shared Drives and reaches for corpora:'allDrives' for team/shared docs (or when a default search returns nothing).
  • Remove the dead 'drive' corpus value — it requires a driveId no action sends (always 400s) and can't be stored as an org setting (OrgSettings.driveCorpora is 'user' | 'domain' | 'allDrives'). 'allDrives' already covers shared drives.
  • New e2e test (drive-search-corpora.test.ts) drives executeDriveAction against a mocked Drive API and asserts: default stays 'user'; opting into 'allDrives' (per-request or the org driveCorpora setting) returns a shared-drive doc; the removed 'drive' value is rejected without hitting the API.

Drive-by

Classify docs.find_text_index in the labels guard. It was registered but uncategorized, so it was fail-closed-denied whenever the guard is active, and it broke the guard's classification-completeness test (already red on main). One-line fix → suite is green.

Deferred (separate decision)

Widening the org-wide default corpus from 'user''allDrives' (resolver + org default + a migration flipping existing rows) would fix this automatically for every org, but it's a behavioral change with a privacy-perception angle and Google's "incomplete results on very large workspaces" caveat. Flagged to @yourbuddyconner (TKAI-49 author) as its own call.

Test plan

cd packages/plugin-google-workspace && pnpm test
  • drive-search-corpora.test.ts — 6 new e2e cases ✅
  • resolve-corpora.test.ts — updated for 'drive' removal ✅
  • labels-guard.test.ts — now green (find_text_index classified) ✅
  • Full package suite: 37 passed, tsc --noEmit clean

…corpora

Drive list/search default to corpora='user', which is My Drive only and
excludes files that live in a Shared Drive (Team Drive) — so team/shared
docs silently never appear in search. The supportsAllDrives /
includeItemsFromAllDrives flags don't help: they are capability flags, not
corpus-wideners. (The root cause is the corpus, not the OAuth scope — the
integration already holds the full auth/drive grant.)

Conservative fix (no change to the default corpus):
- Rewrite the tool descriptions and the google-drive skill to state that
  'user' excludes Shared Drives and to use corpora='allDrives' for
  team/shared docs or when a default search comes up empty.
- Remove the dead 'drive' corpus value: it requires a driveId no action
  sends (always 400s) and cannot be stored as an org setting. 'allDrives'
  already covers shared drives.
- Add an e2e test that drives executeDriveAction with a mocked Drive API:
  asserts the default stays 'user', that opting into 'allDrives'
  (per-request or org setting) returns a shared-drive doc, and that the
  removed 'drive' value is rejected.

Drive-by: classify docs.find_text_index in the labels guard. It was
registered but uncategorized, so it was fail-closed-denied when the guard
is active and broke the guard's classification-completeness test.

Widening the org-wide default corpus to 'allDrives' is deferred as a
separate product decision.
@xBalbinus xBalbinus requested a review from a team June 25, 2026 18:35
@github-actions

Copy link
Copy Markdown

Preview deployment: https://pr-59.dev-valet-turnkey-client.pages.dev

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.

1 participant