Skip to content

search_drive_files: surface lastModifyingUser, createdTime, and anyon…#791

Open
cosmic-fire-eng wants to merge 1 commit into
taylorwilsdon:mainfrom
c6-hub:main
Open

search_drive_files: surface lastModifyingUser, createdTime, and anyon…#791
cosmic-fire-eng wants to merge 1 commit into
taylorwilsdon:mainfrom
c6-hub:main

Conversation

@cosmic-fire-eng
Copy link
Copy Markdown

@cosmic-fire-eng cosmic-fire-eng commented May 14, 2026

…e-permission role (#1)

Expand the Drive API fields parameter and response formatter so that search_drive_files returns the metadata needed for public link audits: createdTime, lastModifyingUser (displayName + email), and the role on any "anyone" permission (reader/commenter/writer).

No OAuth scope changes required. Created By (via owners) is intentionally omitted for Shared Drive files — see TODO comment for the revisions API workaround.

Description

Brief description of the changes in this PR.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this change manually

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have enabled "Allow edits from maintainers" for this pull request

Additional Notes

Add any other context about the pull request here.


⚠️ IMPORTANT: This repository requires that you enable "Allow edits from maintainers" when creating your pull request. This allows maintainers to make small fixes and improvements directly to your branch, speeding up the review process.

To enable this setting:

  1. When creating the PR, check the "Allow edits from maintainers" checkbox
  2. If you've already created the PR, you can enable this in the PR sidebar under "Allow edits from maintainers"

Summary by CodeRabbit

  • New Features

    • Enhanced detailed file information display to include creation date, last editor attribution (name and email), and "Anyone with link" sharing status.
  • Tests

    • Expanded test coverage for new metadata fields in detailed file output and API field requests.

Review Change Stack

…e-permission role (#1)

Expand the Drive API fields parameter and response formatter so that
search_drive_files returns the metadata needed for public link audits:
createdTime, lastModifyingUser (displayName + email), and the role on
any "anyone" permission (reader/commenter/writer).

No OAuth scope changes required. Created By (via owners) is intentionally
omitted for Shared Drive files — see TODO comment for the revisions API
workaround.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

This PR expands detailed-mode search functionality for Google Drive files. The API now requests creation time, last-modifying user, and file permissions data, which are then formatted and displayed with created timestamp, last editor attribution, and public link sharing indicators.

Changes

Detailed Drive Metadata Enhancement

Layer / File(s) Summary
Test helper expansion for new metadata fields
tests/gdrive/test_drive_tools.py
_make_file helper now accepts optional created, last_modifying_user, and permissions parameters to construct mocked Drive items with newly supported metadata fields.
Drive API field expansion for detailed mode
gdrive/drive_helpers.py, tests/gdrive/test_drive_tools.py
build_drive_list_params adds permissions(id, type, role) to the API fields projection when detailed=True; tests verify the new fields are requested for detailed mode and omitted for non-detailed mode.
Item output formatting and field request validation
gdrive/drive_tools.py, tests/gdrive/test_drive_tools.py
search_drive_files detailed output now includes formatted creation time, last editor attribution from lastModifyingUser, and anyone-with-link permission indicator; new tests validate output rendering and verify expanded API fields are passed correctly through the integration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • taylorwilsdon/google_workspace_mcp#515: Introduced the initial detailed flag wiring and conditional formatting in build_drive_list_params and search_drive_files, upon which this PR's expanded metadata handling is built.

Suggested labels

enhancement

Poem

🐰 More details in Drive, what a delight!
Creation times and editors in sight,
Who shares with all? Now we know the way,
Google files reveal more each day!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is truncated and incomplete; it cuts off mid-word ('anyon…'), making it unclear and not fully representative of the changes. Complete the title to read: 'search_drive_files: surface lastModifyingUser, createdTime, and anyone-permission role' without truncation.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The PR description includes a clear, informative preamble explaining the changes and reasoning, followed by the required template structure; all major sections are present though Type/Testing/Checklist boxes are unchecked.
Docstring Coverage ✅ Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@gdrive/drive_helpers.py`:
- Around line 209-215: The shared build_drive_list_params currently always
requests createdTime, lastModifyingUser and permissions which bloats responses;
add a boolean parameter (e.g., include_creator_and_perms) to
build_drive_list_params and use it to conditionally append "createdTime,
lastModifyingUser(...), permissions(...)" to the fields string, then update
callers: call build_drive_list_params(include_creator_and_perms=True) from
search_drive_files (which needs those fields) and call it with False from
list_drive_items so list_drive_items only fetches size, driveId, modifiedTime,
webViewLink; keep the existing field fragments and symbol names
(build_drive_list_params, search_drive_files, list_drive_items) so changes are
minimal and clearly gated by the new flag.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 78c5cc0a-1eb2-428d-b692-cc8e665e9916

📥 Commits

Reviewing files that changed from the base of the PR and between 5495c83 and 32a8d8f.

📒 Files selected for processing (3)
  • gdrive/drive_helpers.py
  • gdrive/drive_tools.py
  • tests/gdrive/test_drive_tools.py

Comment thread gdrive/drive_helpers.py
Comment on lines 209 to +215
if detailed:
fields = "nextPageToken, files(id, name, mimeType, webViewLink, iconLink, modifiedTime, size, driveId)"
fields = (
"nextPageToken, files(id, name, mimeType, webViewLink, iconLink,"
" modifiedTime, createdTime, size, driveId,"
" lastModifyingUser(displayName, emailAddress),"
" permissions(id, type, role))"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Call sites of build_drive_list_params =="
rg -n "build_drive_list_params\\(" gdrive/drive_tools.py

echo
echo "== search_drive_files uses newly requested fields in output =="
rg -n -C2 "Created:|Last Edited By:|Anyone with link|createdTime|lastModifyingUser|permissions" gdrive/drive_tools.py

echo
echo "== list_drive_items formatted output fields =="
rg -n -C3 "def list_drive_items|Size:|Drive ID:|Modified:|Link:" gdrive/drive_tools.py

Repository: taylorwilsdon/google_workspace_mcp

Length of output: 17629


🏁 Script executed:

# Check the build_drive_list_params function implementation and its signature
head -n 220 gdrive/drive_helpers.py | tail -n 25

Repository: taylorwilsdon/google_workspace_mcp

Length of output: 1288


🏁 Script executed:

# See context around line 216 call
sed -n '210,225p' gdrive/drive_tools.py

Repository: taylorwilsdon/google_workspace_mcp

Length of output: 612


🏁 Script executed:

# See context around line 692 call
sed -n '685,700p' gdrive/drive_tools.py

Repository: taylorwilsdon/google_workspace_mcp

Length of output: 677


🏁 Script executed:

# Check if list_drive_items uses any of the disputed fields in output
sed -n '613,730p' gdrive/drive_tools.py | grep -n "createdTime\|lastModifyingUser\|permissions" || echo "No matches found in list_drive_items output"

Repository: taylorwilsdon/google_workspace_mcp

Length of output: 289


Gate specialized fields in build_drive_list_params by caller to prevent unnecessary response bloat.

search_drive_files uses createdTime, lastModifyingUser, and permissions in its output (lines 239, 244, 260), but list_drive_items does not use any of these fields—it only outputs size, driveId, modifiedTime, and webViewLink (lines 715–720). Both functions call the shared build_drive_list_params with the same parameters, causing list_drive_items to fetch and deserialize unnecessary fields with every API call. Add a parameter (e.g., include_creator_and_perms) or extend the field specification to let each caller request only what it needs. This aligns with the coding guideline: "Response payloads must be concise."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@gdrive/drive_helpers.py` around lines 209 - 215, The shared
build_drive_list_params currently always requests createdTime, lastModifyingUser
and permissions which bloats responses; add a boolean parameter (e.g.,
include_creator_and_perms) to build_drive_list_params and use it to
conditionally append "createdTime, lastModifyingUser(...), permissions(...)" to
the fields string, then update callers: call
build_drive_list_params(include_creator_and_perms=True) from search_drive_files
(which needs those fields) and call it with False from list_drive_items so
list_drive_items only fetches size, driveId, modifiedTime, webViewLink; keep the
existing field fragments and symbol names (build_drive_list_params,
search_drive_files, list_drive_items) so changes are minimal and clearly gated
by the new flag.

@taylorwilsdon taylorwilsdon self-assigned this May 17, 2026
@taylorwilsdon taylorwilsdon added the enhancement New feature or request label May 17, 2026
@taylorwilsdon
Copy link
Copy Markdown
Owner

This seems to go hand in hand with #783 - let me see if we can't combine the two

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants