Skip to content

Conversation

@aadamgough
Copy link
Contributor

Summary

Added shared drive file access that was missing.

Fixes #(issue)

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 7, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Dec 7, 2025 0:20am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 7, 2025

Greptile Overview

Greptile Summary

Comprehensively adds Google Shared Drive support across all Google Drive, Docs, and Slides operations by adding supportsAllDrives=true and corpora=allDrives parameters to API requests.

Key Changes:

  • Added fallback logic to detect and handle shared drives when file lookup returns 404
  • Implemented fetchSharedDrives() function to list shared drives in root folder views
  • Updated all Google Drive API calls with supportsAllDrives=true parameter for file operations
  • Changed list/search queries to use corpora=allDrives instead of spaces=drive for cross-drive search
  • Applied shared drive support to create operations for Google Docs and Slides

Implementation Quality:

  • Proper error handling with graceful degradation (returns empty array if shared drives fetch fails)
  • Consistent application of parameters across all API endpoints
  • Good logging for debugging shared drive operations
  • Type safety improvements with TypeScript interfaces

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward additions of Google Drive API parameters for shared drive support. All modifications follow Google's documented API patterns, include proper error handling, and maintain backward compatibility. No breaking changes or risky logic introduced.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/api/tools/drive/file/route.ts 5/5 Added fallback to check shared drives when file not found (404), and added supportsAllDrives=true to download URLs
apps/sim/app/api/tools/drive/files/route.ts 5/5 Added fetchSharedDrives function, changed query to use corpora=allDrives, and includes shared drives in root folder listings
apps/sim/tools/google_drive/list.ts 5/5 Added corpora=allDrives parameter to search across shared drives, removed spaces=drive parameter

Sequence Diagram

sequenceDiagram
    participant User
    participant API as Drive Files API
    participant GoogleDrive as Google Drive API
    participant SharedDrives as Shared Drives API
    
    User->>API: GET /api/tools/drive/files (root folder)
    API->>GoogleDrive: List files (corpora=allDrives)
    GoogleDrive-->>API: Return user files
    API->>SharedDrives: Fetch shared drives
    SharedDrives-->>API: Return shared drives list
    API->>API: Merge shared drives + files
    API-->>User: Combined file list
    
    User->>API: GET /api/tools/drive/file (fileId)
    API->>GoogleDrive: Get file metadata (supportsAllDrives=true)
    alt File found
        GoogleDrive-->>API: File metadata
        API-->>User: Return file
    else 404 Not Found
        API->>SharedDrives: Try as shared drive ID
        alt Is shared drive
            SharedDrives-->>API: Shared drive metadata
            API-->>User: Return as folder
        else Not found
            API-->>User: 404 error
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 683b447 into staging Dec 7, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/google-drive branch December 7, 2025 01:37
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.

3 participants