Skip to content

Commit 5d38703

Browse files
authored
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`.
1 parent e99e5a8 commit 5d38703

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

unstructured/ingest/v2/processes/connectors/google_drive.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ def is_dir(record: dict) -> bool:
129129
def map_file_data(f: dict) -> FileData:
130130
file_id = f["id"]
131131
filename = f.pop("name")
132-
url = f.pop("webContentLink")
132+
url = f.pop("webContentLink", None)
133133
version = f.pop("version", None)
134134
permissions = f.pop("permissions", None)
135-
date_created_str = f.pop("createdTime")
136-
date_created_dt = parser.parse(date_created_str)
137-
date_modified_str = f.pop("modifiedTime")
135+
date_created_str = f.pop("createdTime", None)
136+
date_created_dt = parser.parse(date_created_str) if date_created_str else None
137+
date_modified_str = f.pop("modifiedTime", None)
138138
parent_path = f.pop("parent_path", None)
139139
parent_root_path = f.pop("parent_root_path", None)
140-
date_modified_dt = parser.parse(date_modified_str)
140+
date_modified_dt = parser.parse(date_modified_str) if date_modified_str else None
141141
if (
142142
parent_path
143143
and isinstance(parent_path, str)

0 commit comments

Comments
 (0)