Skip to content

bug(drive): search does not find files on shared drives (missing corpora=allDrives) #147

Description

@saxyguy81

Problem

gog drive search does not return files that live exclusively on shared drives. The same files are accessible via gog drive get <fileId> and gog drive ls --parent <folderID>, and are searchable in the Google Drive web UI.

Root Cause

The drive search command sets IncludeItemsFromAllDrives(true) and SupportsAllDrives(true) on the API call, but does not set Corpora("allDrives"). Without the corpora parameter, the Google Drive API defaults to corpora=user, which only searches the user's My Drive.

Per the Google Drive API docs:

corpora — Bodies of items (files/documents) to which the query applies. Supported bodies are user, domain, drive, and allDrives. Prefer user or drive to allDrives for efficiency. By default, corpora is set to user.

Reproduction

# Account that ONLY has access via a shared drive (no personal files):
gog drive search "test" --account user@example.com
# → No results

# But direct access works:
gog drive get <fileId-from-shared-drive> --account user@example.com
# → Returns file metadata

# And listing by parent folder works:
gog drive ls --parent <shared-drive-folder-id> --account user@example.com
# → Returns files

Verification

A raw API call with corpora=allDrives using the same OAuth token returns results correctly:

curl "https://www.googleapis.com/drive/v3/files?q=fullText+contains+'test'&includeItemsFromAllDrives=true&supportsAllDrives=true&corpora=allDrives" \
  -H "Authorization: Bearer $ACCESS_TOKEN"
# → Returns shared drive files

Suggested Fix

Add .Corpora("allDrives") to the files.list call in the search command (and ideally drive ls as well). This could be:

  1. Always-on (safest default — matches web UI behavior), or
  2. Behind a flag like --corpora allDrives or --include-shared-drives

Option 1 is simpler and matches user expectations since IncludeItemsFromAllDrives and SupportsAllDrives are already set.

Environment

  • gog v0.9.0
  • Google Workspace account with shared drive access
  • macOS (Homebrew install)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions