bugfix: google drive connector metadata safegaurds (#3407)

### Description

At times, the google drive response doens't have some of the metadata
we're grabbing to populate the `FileData` metadata. This is fine, but
without the added safegaurds, this can cause a `KeyError`.
This commit is contained in:
Roman Isecke 2024-07-18 12:09:19 -04:00 committed by GitHub
parent e99e5a8abd
commit 5d387030eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -129,15 +129,15 @@ class GoogleDriveIndexer(Indexer):
def map_file_data(f: dict) -> FileData:
file_id = f["id"]
filename = f.pop("name")
url = f.pop("webContentLink")
url = f.pop("webContentLink", None)
version = f.pop("version", None)
permissions = f.pop("permissions", None)
date_created_str = f.pop("createdTime")
date_created_dt = parser.parse(date_created_str)
date_modified_str = f.pop("modifiedTime")
date_created_str = f.pop("createdTime", None)
date_created_dt = parser.parse(date_created_str) if date_created_str else None
date_modified_str = f.pop("modifiedTime", None)
parent_path = f.pop("parent_path", None)
parent_root_path = f.pop("parent_root_path", None)
date_modified_dt = parser.parse(date_modified_str)
date_modified_dt = parser.parse(date_modified_str) if date_modified_str else None
if (
parent_path
and isinstance(parent_path, str)