fix: support Google Shared Drives in gdrive connector#72
Open
joelchrist wants to merge 1 commit into
Open
Conversation
The Drive API does not return items from Shared Drives (formerly Team Drives) unless requests opt in with supportsAllDrives and includeItemsFromAllDrives. Without them, syncing a folder inside a Shared Drive listed no files and reported "nothing to do", even with correct service-account permissions. Add these flags to all files.list calls in _walk_folder and _find_file, and pass supportsAllDrives to the file get/get_media download calls so Shared Drive files can be fetched. Fixes open-webui#52 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #52 — the
gdriveconnector reported "nothing to do" when the target folder lives inside a Google Shared Drive (formerly Team Drive), even with correct service-account permissions.The Drive API's
files.listdoes not return items from Shared Drives unless the request opts in withsupportsAllDrives=TrueandincludeItemsFromAllDrives=True. Personal "My Drive" folders work because they don't require these flags — which is why the connector worked in that case but silently returned an empty listing for Shared Drives.Changes
src/oikb/connectors/gdrive.py:supportsAllDrives=TrueandincludeItemsFromAllDrives=Trueto allfiles.listcalls — one in_walk_folder()and both in_find_file().supportsAllDrives=Truetofiles.getandfiles.get_mediainread_file()so Shared Drive files can be downloaded. (files.exportaccepts onlyfileId/mimeTypeand works by ID, so it is left unchanged.)The flags are a no-op for My Drive folders, so existing behaviour is unchanged.
Testing
python -m py_compile src/oikb/connectors/gdrive.pypasses.oikb diff gdrive:<shared-drive-folder-id> --kb-id <kb>now lists files instead of reporting "nothing to do".🤖 Generated with Claude Code