Skip to content

Commit 31119b7

Browse files
devin-ai-integration[bot]bot_apk
andcommitted
fix: improve ERROR_READING_FILE message and raise AirbyteTracedException with system_error
Replace misleading credential-focused error message with accurate 'File read failed during availability check.' message. Raise AirbyteTracedException with FailureType.system_error instead of CheckAvailabilityError, since the error is not necessarily caused by invalid credentials. Resolves airbytehq/airbyte-internal-issues#16082 Co-Authored-By: bot_apk <apk@cognition.ai>
1 parent 0e57414 commit 31119b7

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

airbyte_cdk/sources/file_based/availability_strategy/default_file_based_availability_strategy.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import TYPE_CHECKING, Optional, Tuple
1010

1111
from airbyte_cdk import AirbyteTracedException
12+
from airbyte_cdk.models import FailureType
1213
from airbyte_cdk.sources import Source
1314
from airbyte_cdk.sources.file_based.availability_strategy import (
1415
AbstractFileBasedAvailabilityStrategy,
@@ -133,8 +134,10 @@ def _check_parse_record(
133134
except AirbyteTracedException as ate:
134135
raise ate
135136
except Exception as exc:
136-
raise CheckAvailabilityError(
137-
FileBasedSourceError.ERROR_READING_FILE, stream=stream.name, file=file.uri
137+
raise AirbyteTracedException(
138+
message=FileBasedSourceError.ERROR_READING_FILE.value,
139+
internal_message=f"Error reading file {file.uri} in stream {stream.name}: {exc}",
140+
failure_type=FailureType.system_error,
138141
) from exc
139142

140143
schema = stream.catalog_schema or stream.config.input_schema

airbyte_cdk/sources/file_based/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FileBasedSourceError(Enum):
1717
ERROR_CASTING_VALUE_UNRECOGNIZED_TYPE = "Could not cast the value to the expected type because the type is not recognized. Valid types are null, array, boolean, integer, number, object, and string."
1818
ERROR_DECODING_VALUE = "Expected a JSON-decodeable value but could not decode record."
1919
ERROR_LISTING_FILES = "Error listing files. Please check the credentials provided in the config and verify that they provide permission to list files."
20-
ERROR_READING_FILE = "Error opening file. Please check the credentials provided in the config and verify that they provide permission to read files."
20+
ERROR_READING_FILE = "File read failed during availability check."
2121
ERROR_PARSING_RECORD = "Error parsing record. This could be due to a mismatch between the config's file type and the actual file type, or because the file or record is not parseable."
2222
ERROR_PARSING_USER_PROVIDED_SCHEMA = (
2323
"The provided schema could not be transformed into valid JSON Schema."

unit_tests/sources/file_based/scenarios/check_scenarios.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
from airbyte_cdk.sources.file_based.exceptions import FileBasedSourceError
6+
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
67
from unit_tests.sources.file_based.helpers import (
78
FailingSchemaValidationPolicy,
89
TestErrorListMatchingFilesInMemoryFilesStreamReader,
@@ -158,7 +159,7 @@
158159
)
159160
)
160161
)
161-
.set_expected_check_error(None, FileBasedSourceError.ERROR_READING_FILE.value)
162+
.set_expected_check_error(AirbyteTracedException, FileBasedSourceError.ERROR_READING_FILE.value)
162163
).build()
163164

164165

@@ -222,5 +223,5 @@
222223
],
223224
}
224225
)
225-
.set_expected_check_error(None, FileBasedSourceError.ERROR_READING_FILE.value)
226+
.set_expected_check_error(AirbyteTracedException, FileBasedSourceError.ERROR_READING_FILE.value)
226227
).build()

0 commit comments

Comments
 (0)