From eeb844e35e448f1a8235367b21502550bae1738a Mon Sep 17 00:00:00 2001 From: Weves Date: Mon, 20 Nov 2023 16:26:42 -0800 Subject: [PATCH] Fix bug with Google Drive shortcut error case --- .../connectors/google_drive/connector.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/backend/danswer/connectors/google_drive/connector.py b/backend/danswer/connectors/google_drive/connector.py index 31a1cc32fb7..31bb31ffc73 100644 --- a/backend/danswer/connectors/google_drive/connector.py +++ b/backend/danswer/connectors/google_drive/connector.py @@ -101,12 +101,18 @@ def _run_drive_file_query( for file in files: if follow_shortcuts and "shortcutDetails" in file: try: - file = service.files().get( - fileId=file["shortcutDetails"]["targetId"], - supportsAllDrives=include_shared, - fields="mimeType, id, name, modifiedTime, webViewLink, shortcutDetails", - ) - file = add_retries(lambda: file.execute())() + file_shortcut_points_to = add_retries( + lambda: ( + service.files() + .get( + fileId=file["shortcutDetails"]["targetId"], + supportsAllDrives=include_shared, + fields="mimeType, id, name, modifiedTime, webViewLink, shortcutDetails", + ) + .execute() + ) + )() + yield file_shortcut_points_to except HttpError: logger.error( f"Failed to follow shortcut with details: {file['shortcutDetails']}" @@ -114,7 +120,8 @@ def _run_drive_file_query( if continue_on_failure: continue raise - yield file + else: + yield file def _get_folder_id(