Skip to content

feat(google): Search only files the requester could find - #3208

Merged
dcramer merged 9 commits into
mainfrom
feat/google-search-findable
Nov 12, 2026
Merged

dcramer merged 9 commits into
mainfrom
feat/google-search-findable

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Narrows searchGoogleFiles to files the requester could find in Drive themselves. Today, search returns anything shared with Junior's account. Reads by link are unchanged.

Changes

  • Search filter. Search runs two Drive queries. Both include the requester's words, the type filter, and trashed = false:
    named:    ('<requester>' in readers or '<requester>' in writers or '<requester>' in owners)
    findable: (visibility = 'domainCanFind' or visibility = 'anyoneCanFind')
    
    Link-only files and files shared only with other people or groups match neither query.
  • Owner-domain guard. Search drops a result when no account in GOOGLE_WORKSPACE_ALLOWED_DOMAINS owns it, because domainCanFind does not say which domain. Shared-drive files have no owners, so they show only when the named query finds them. A file with no owner data never shows.
  • Fails closed. If the requester's email is unknown or outside the allowed domains, or Google rejects a query, search refuses with a PluginToolInputError that asks for a link. It never retries without the filter.

Known concerns

  • The Drive docs define visibility and in readers/writers/owners. They do not say whether these terms behave the same when Junior's account can only view a file, or how shared drives and group grants match. These need a live check.
  • Search finds far fewer Docs than before. Most Docs are shared by link, and the guard also drops domain-findable shared-drive files that do not name the requester.
  • Meet transcripts and Gemini notes are shared with every invitee, Junior's account too. Like any Doc shared with Junior, anyone who has a record's link can read it through Junior. Search shows a record only to people named on it. readMeetingTranscript stays the invite-checked path from a calendar event.
  • allowedDomains now also decides file ownership for search. This assumes that every allowed domain is part of the company Workspace.

Testing

  • packages/junior-google: 34 tests pass. They cover both queries, the owner guard, an unknown or outside requester, and a rejected query.
  • Typecheck, lint, the tool-error check, and the repo-wide pre-push lint pass.

via @dcramer.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 12, 2026 7:31pm UTC

Request Review

@dcramer

dcramer commented Nov 12, 2026

Copy link
Copy Markdown
Member

Is there anything else you can do to provide evidence that the APIs you're using will correctly limit this? It's OK to accidentally limit it too much, but it's not OK to expose things that shouldn't be exposed

@sentry-junior

sentry-junior Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Short version: Google's docs support the filter, but they don't prove it. I found one real gap, and only a live run with fixture files can give hard evidence. I can't run that from here, because sandbox commands get no Google credential and the google tools take words, not a raw Drive query.

What the docs support (search terms, examples)

  • readers/writers/owners are "users or groups who have permission", and they "refer to the role on the permission". So '<requester>' in readers matches a permission that names the requester's email. Domain and anyone-with-link grants name no email, so link sharing should not match. Group grants match only the group address (the docs use '[email protected]' in writers), so a group-only file is excluded. That is too strict, not a leak.
  • visibility is a property of the file, with five distinct values. limited means "private, or shared with specific users or groups". domainWithLink and anyoneWithLink are separate values, so = 'domainCanFind' or = 'anyoneCanFind' leaves them out.
  • Every term is ANDed onto the requester's words and the type filter, and a rejected query returns no files.

Not covered by the docs (needs a live check)

  • Whether visibility and in readers work the same when the caller (Junior's account) can only view the file.
  • Whether Google ignores a term it doesn't support instead of rejecting it. If it ignores the term, that is a leak.

Real gap: domainCanFind doesn't say which domain. Say someone at another company shares a Doc with Junior's account by name, and that Doc is also findable by everyone at their company. It matches visibility = 'domainCanFind', so any Sentry employee could find it through Junior. A fix that errs on the strict side: request owners(emailAddress) and driveId, and drop any result that has no owner in allowedDomains. The catch is that files in shared drives have no owners, so the strict version also drops domain-findable files in shared drives, unless the requester is named on them. That could remove a lot of company docs from search. Your call.

What I can do next

  1. Add the owner-domain guard above (small change, plus tests).
  2. Add a live check script to this package. It runs the exact query clause against a set of fixture files and exits non-zero if a file shows up that shouldn't. One file per case: private to someone else, shared with the requester as viewer and as commenter, domain link-only, anyone link-only, domain-findable, group-only, external domain-findable, and a shared drive file. Someone with Junior's Google account creates the fixtures once and runs it. I can't do that part.
  3. Until 2 passes, ship search turned off, and keep reads by link.

If you want hard evidence before merge, I'd do 1 and 2.

…p search off until it passes

Co-Authored-By: David Cramer <[email protected]>
@dcramer

dcramer commented Nov 12, 2026

Copy link
Copy Markdown
Member

this is primarily an improvement upon what we have today so we'll be able to verify life. clean up the PR description so it focuses on whats in this PR, and the known concerns

@dcramer

dcramer commented Nov 12, 2026

Copy link
Copy Markdown
Member

remove this verify-search junk. we dont ship things like that to prod. you follow the docs, implement it per spec, make sure your code is correct, and thats the limit of your job.

@dcramer

dcramer commented Nov 12, 2026

Copy link
Copy Markdown
Member

i dont want a constant like this to turn it on/off. we could use an experiment temporarily, but our goal is to make the bot behave well not have a ton of variable behaviors we have to think about this

@dcramer
dcramer marked this pull request as ready for review November 12, 2026 18:49
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 12, 2026
@dcramer

dcramer commented Nov 12, 2026

Copy link
Copy Markdown
Member

does the meet handling even make sense? i get having the calendar events be meeting transcript aware, but thats different than trying to special case all those files

@sentry-junior

sentry-junior Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Fair challenge. I don't think the file-side special case earns its keep.

The only argument for it: Meet shares records with every invitee automatically, so Junior's account gets transcripts just by being on an invite, not because someone chose to share them with Junior. But under this PR's model, reading one still needs the link. Someone holding the link of a meeting they weren't in is the same case as holding the link of any private Doc shared with Junior, and we already accept that for every other Doc.

Search doesn't leak them either. Meet records aren't domainCanFind, so they only show through the named query, which means the requester is on the file, which means they were invited.

The title match is also the weakest part of the PR. It refuses ordinary files with "transcript" or "Gemini" in the name, it misses renamed records, and it pulled in the record input on readMeetingTranscript just to give the refusal somewhere to point.

My proposal: drop the Meet title refusal from the file readers, drop the record input, and keep readMeetingTranscript as the event-based, invite-checked path. Record links then read like any other Doc shared with Junior. Want me to make that change?

@sentry-junior

sentry-junior Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Following up on #3208 (comment): done in 8b56f95.

  • The file readers no longer refuse Meet-record titles. A record link reads like any other Doc shared with Junior.
  • readMeetingTranscript is back to taking only event_id, with its existing invite check. The record input, its calendar lookup and its tests are gone.
  • README and PR body updated. The PR now only changes search.

This reverses the earlier fix for the Warden finding on localized Meet titles. That's on purpose: under this model, a record link is treated like any other Doc link.

@dcramer
dcramer merged commit d497402 into main Nov 12, 2026
45 checks passed
@dcramer
dcramer deleted the feat/google-search-findable branch November 12, 2026 19:47
BYK added a commit that referenced this pull request Nov 13, 2026
## Problem

A Google Docs, Sheets, Slides, or Calendar event link in a Conversation,
an Inbox row, or a hover card shows as a bare link. The Google plugin
has no Google credentials for each viewer. It reads only as Junior's own
Workspace account. Also, a link resolver gets no provider credentials at
all.

## Fix

**Core: `egress` on `ObjectLinkContext`.** A link resolver gets the same
host-owned `PluginEgress` that tools use. Junior builds it for a system
Actor (`object-link`). It gets only credentials that the plugin owns,
such as an app or Junior's account, and never the viewer's. It never
asks anyone to authorize. The title-context hook already uses this
shape. I chose it over a plugin-owned credential read because the plugin
keeps its operation allowlist (`grantForEgress`), lease caching, and
audit, and no plugin reads tokens itself. Resolvers that do not use
`egress` do not change. No new OAuth scopes, no migration.

**Google plugin: two link types.** Each one checks that the viewer could
open the object.

- Docs, Sheets, and Slides. The filters are `docs.google.com` with
`pathPrefix` `/document/d/`, `/spreadsheets/d/`, and `/presentation/d/`,
plus the signed-in `/u/` forms such as `/document/u/0/d/`. Junior reads
the file metadata. Then it asks Drive, limited to files with that name,
if one of these is true:
  - The file names the viewer's email as a reader, writer, or owner.
  - The file is `anyoneWithLink` or `anyoneCanFind`.
- The file is `domainWithLink` or `domainCanFind`, the viewer's domain
is in `GOOGLE_WORKSPACE_ALLOWED_DOMAINS`, and an owner is in that
domain. A shared-drive file has no owner, so only a share that names the
viewer counts.

This is the rule of `searchGoogleFiles` (#3208). A share to a group does
not name the viewer, so it gets no card. A file of the wrong type, in
the trash, after the first 100 results, or in a rejected query also gets
no card.
- Calendar events. The filters are `calendar.google.com` and
`www.google.com` with the path `/calendar/event`, and
`calendar.google.com` with `/calendar/r/eventedit/*` and
`/calendar/u/*/r/eventedit/*`. The `eid` must name Junior's calendar.
The event must list the viewer as organizer, creator, or attendee.
- Card contents:
- A file card has the title, type (`Google Doc`, `Google Sheet`, or
`Google Slides`), owner, and modified time.
- An event card has the title and time. The time is the start and end in
the event's own time zone, or the date of an all-day event. The resolver
does not know the viewer's time zone, and the dashboard shows `when` as
text.
  - Cards have no content, no guests, and no images.
- New object type `document` (Octicon `file`) with the facts `owner` and
`modifiedAt`. Calendar uses the existing `calendar_event`.

## Tests

- `tests/integration/api/object-link-egress.test.ts`: a plugin link type
reads through `/api/objects` with its own lease. The credential Actor is
the system Actor, not the viewer. The test fails without the core
change.
- `junior-google/tests/links.test.ts`:
- Files: a signed-in `/u/1/` link matches and resolves. A viewer that
the file names and a viewer in the file's domain get a card. These get
no card: a viewer that the file does not name, a viewer outside the
domain (Junior does not send the domain query), a share only to a group,
a file that Junior cannot open, and a link of the wrong type.
- Calendar: an attendee gets a card with the event time, and the card
has no guest email. An all-day event shows its date. An event with a
guest that has no email still resolves. A viewer who is not on the event
gets no card. A link to another calendar gets no card, and Junior sends
no Google request for it.
- Dashboard e2e: the Doc and Calendar links show as chips and hover
cards, and the event card shows the time. The existing object-link test
now waits for resolved links before it hovers, because a late render
could drop the hover when the file ran in parallel.
- Also ran `pnpm typecheck`, `pnpm lint`, the dashboard and plugin-api
unit tests, and the dashboard e2e.

## Screenshots (1440 wide)

Google Doc

| | Before | After |
| --- | --- | --- |
| Dark | ![doc before
dark](https://junior-prod.sentry.dev/public/artifacts/6909c3cd-6f5d-471b-a749-1909b4f4c86d.png)
| ![doc after
dark](https://junior-prod.sentry.dev/public/artifacts/ea5dbfb0-018e-482e-a113-88f39286c191.png)
|
| Light | ![doc before
light](https://junior-prod.sentry.dev/public/artifacts/20b6a6fd-e3b2-473b-9166-e5d5c01f3649.png)
| ![doc after
light](https://junior-prod.sentry.dev/public/artifacts/2e9f79b4-376c-4dad-a81c-c0f66dc9fc25.png)
|

Calendar event

| | Before | After |
| --- | --- | --- |
| Dark | ![event before
dark](https://junior-prod.sentry.dev/public/artifacts/7eb8ab5b-abdc-4899-a07e-193f5de4817e.png)
| ![event after
dark](https://junior-prod.sentry.dev/public/artifacts/d70b432f-6641-4342-aa61-a8e337c0e947.png)
|
| Light | ![event before
light](https://junior-prod.sentry.dev/public/artifacts/46f4232b-6944-4922-911a-9a742c93db25.png)
| ![event after
light](https://junior-prod.sentry.dev/public/artifacts/e924f299-632b-4723-af47-3fc55df7f887.png)
|

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Ab4ab1661aa9222ed540303a34bce2d99 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Ab4ab1661aa9222ed540303a34bce2d99)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ab4ab1661aa9222ed540303a34bce2d99/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 0115b2c3 Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant