Skip to content

Commit ab5d4e7

Browse files
committed
file-api: add checks for missin values/paths
1 parent 87c20b6 commit ab5d4e7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

airbyte_cdk/sources/declarative/retrievers/file_uploader.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ def __post_init__(self, parameters: Mapping[str, Any]) -> None:
4545
def upload(self, record: Record) -> None:
4646
mocked_response = SafeResponse()
4747
mocked_response.content = json.dumps(record.data).encode()
48-
download_target = list(self.download_target_extractor.extract_records(mocked_response))[0]
48+
download_targets = list(self.download_target_extractor.extract_records(mocked_response))
49+
if not download_targets:
50+
raise ValueError("No download targets found")
51+
52+
download_target = download_targets[0] # we just expect one download target
4953
if not isinstance(download_target, str):
5054
raise ValueError(
5155
f"download_target is expected to be a str but was {type(download_target)}: {download_target}"

airbyte_cdk/sources/file_based/file_based_stream_reader.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ def _get_file_transfer_paths(
186186
- FILE_NAME: The name of the referenced file.
187187
- FILE_FOLDER: The folder of the referenced file.
188188
"""
189+
if not path.exists(staging_directory):
190+
raise ValueError(f"Staging directory '{staging_directory}' does not exist")
191+
189192
preserve_directory_structure = self.preserve_directory_structure()
190193

191194
file_name = path.basename(source_file_relative_path)

0 commit comments

Comments
 (0)