Skip to content

fix(drive): include driveId in field masks for list/search/get#524

Open
LeanSheng wants to merge 1 commit intosteipete:mainfrom
LeanSheng:drive-driveid-mask
Open

fix(drive): include driveId in field masks for list/search/get#524
LeanSheng wants to merge 1 commit intosteipete:mainfrom
LeanSheng:drive-driveid-mask

Conversation

@LeanSheng
Copy link
Copy Markdown

@LeanSheng LeanSheng commented Apr 24, 2026

Summary

  • Adds driveId to the shared field mask in driveFileListFields (drives drive ls, drive search) and to the inline Fields(...) call in DriveGetCmd.Run (drive get).
  • The Drive API only returns fields explicitly requested in fields; with driveId omitted, JSON output never included it even for files living in a Shared Drive, making it impossible to distinguish My Drive vs. Shared Drive files from gog output alone.
  • For My Drive files the API omits the field, so existing consumers are unaffected. Shared Drive files now carry driveId through.
  • Adds internal/cmd/drive_driveid_field_test.go pinning driveId in the shared mask constant.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./internal/cmd/... -count=1 -timeout 60s
  • go test ./internal/cmd/... -run TestDriveFileListFields -count=1 -v (new test passes)
  • Manual spot check: gog drive ls --all-drives --format=json on an account with Shared Drive access shows driveId for Shared Drive files and omits it for My Drive files
  • Manual spot check: gog drive get <sharedDriveFileId> --format=json includes driveId

The Drive API only returns fields explicitly requested in the fields
parameter. The previous masks in drive_listing.go (driveFileListFields)
and drive.go (DriveGetCmd) omitted driveId, so JSON output for drive
search, drive ls, and drive get never included driveId — even when
files lived in a Shared Drive.

This made it impossible to distinguish My Drive files from Shared Drive
files in gog output. For users whose work lives primarily in Shared
Drives (common for legal, M&A, and agency deployments), the agent could
not answer 'which drive is this file in?' from gog output alone, falling
back to a raw Drive API call.

The fix adds driveId to both field masks. For My Drive files the Drive
API omits the field from responses, so existing downstream consumers
are unaffected. Shared drive files now carry the correct driveId
through to gog output.

Adds a small regression test pinning driveId in the shared field mask
constant.
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