Skip to content

Commit 07d84bc

Browse files
devin-ai-integration[bot]bot_apk
andcommitted
fix: update AirbyteTracedException.__str__ to show user-facing message
Move the __str__ override from the MessageRepresentationAirbyteTracedErrors subclass into the base AirbyteTracedException class so that str(exception) returns the user-facing message globally, falling back to internal_message. Remove the now-unnecessary MessageRepresentationAirbyteTracedErrors subclass and update the two raise sites in HttpClient to use AirbyteTracedException directly. Co-Authored-By: bot_apk <apk@cognition.ai>
1 parent 7f41401 commit 07d84bc

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

airbyte_cdk/sources/streams/http/http_client.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,6 @@ def monkey_patched_get_item(self, key): # type: ignore # this interface is a co
8282
requests_cache.SQLiteDict.__getitem__ = monkey_patched_get_item # type: ignore # see the method doc for more information
8383

8484

85-
class MessageRepresentationAirbyteTracedErrors(AirbyteTracedException):
86-
"""
87-
Before the migration to the HttpClient in low-code, the exception raised was
88-
[ReadException](https://github.com/airbytehq/airbyte/blob/8fdd9818ec16e653ba3dd2b167a74b7c07459861/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/http_requester.py#L566).
89-
This has been moved to a AirbyteTracedException. The printing on this is questionable (AirbyteTracedException string representation
90-
shows the internal_message and not the message). We have already discussed moving the AirbyteTracedException string representation to
91-
`message` but the impact is unclear and hard to quantify so we will do it here only for now.
92-
"""
93-
94-
def __str__(self) -> str:
95-
if self.message:
96-
return self.message
97-
elif self.internal_message:
98-
return self.internal_message
99-
return ""
100-
101-
10285
class HttpClient:
10386
_DEFAULT_MAX_RETRY: int = 5
10487
_DEFAULT_MAX_TIME: int = 60 * 10
@@ -311,7 +294,7 @@ def _send_with_retry(
311294
return response
312295
except BaseBackoffException as e:
313296
self._logger.error(f"Retries exhausted with backoff exception.", exc_info=True)
314-
raise MessageRepresentationAirbyteTracedErrors(
297+
raise AirbyteTracedException(
315298
internal_message=f"Exhausted available request attempts. Exception: {e}",
316299
message=f"Exhausted available request attempts. Please see logs for more details. Exception: {e}",
317300
failure_type=e.failure_type or FailureType.system_error,
@@ -495,7 +478,7 @@ def _handle_error_resolution(
495478
# ensure the exception message is emitted before raised
496479
self._logger.error(error_message)
497480

498-
raise MessageRepresentationAirbyteTracedErrors(
481+
raise AirbyteTracedException(
499482
internal_message=error_message,
500483
message=error_resolution.error_message or error_message,
501484
failure_type=error_resolution.failure_type,

airbyte_cdk/utils/traced_exception.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ def __init__(
4949
self._stream_descriptor = stream_descriptor
5050
super().__init__(internal_message)
5151

52+
def __str__(self) -> str:
53+
"""Return the user-facing message, falling back to internal_message."""
54+
55+
if self.message:
56+
return self.message
57+
elif self.internal_message:
58+
return self.internal_message
59+
return ""
60+
5261
def as_airbyte_message(
5362
self, stream_descriptor: Optional[StreamDescriptor] = None
5463
) -> AirbyteMessage:

0 commit comments

Comments
 (0)