Skip to content

Commit c7b7944

Browse files
committed
airbyte-cdk: trying to fix unit tests
1 parent 4cdb963 commit c7b7944

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

airbyte_cdk/sources/file_based/file_types/unstructured_parser.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ def parse_records(
162162
logger.warn(f"File {file.uri} cannot be parsed. Skipping it.")
163163
else:
164164
raise e
165+
except Exception as e:
166+
exception_str = str(e)
167+
logger.warn(f"File {file.uri} caused an error during parsing: {exception_str}.")
168+
yield {
169+
"content": None,
170+
"document_key": file.uri,
171+
"_ab_source_file_parse_error": exception_str,
172+
}
173+
logger.warn(f"File {file.uri} cannot be parsed. Skipping it.")
165174

166175
def _read_file(
167176
self,
@@ -186,7 +195,7 @@ def _read_file(
186195
remote_file,
187196
self._get_file_type_error_message(filetype),
188197
)
189-
if filetype in {FileType.MD, filetype is FileType.TXT}:
198+
if filetype in {FileType.MD, FileType.TXT}:
190199
file_content: bytes = file_handle.read()
191200
decoded_content: str = optional_decode(file_content)
192201
return decoded_content

0 commit comments

Comments
 (0)