diff --git a/airbyte_cdk/sources/streams/http/http_client.py b/airbyte_cdk/sources/streams/http/http_client.py index 3a0a62739a..8f70b6e352 100644 --- a/airbyte_cdk/sources/streams/http/http_client.py +++ b/airbyte_cdk/sources/streams/http/http_client.py @@ -58,6 +58,11 @@ ) from airbyte_cdk.utils.traced_exception import AirbyteTracedException +# Backward-compatible deprecated alias. This class was removed in PR #927 but is still +# imported by connectors in the airbyte monorepo. Keep as a simple alias to +# AirbyteTracedException until all downstream usages have been migrated. +MessageRepresentationAirbyteTracedErrors = AirbyteTracedException + BODY_REQUEST_METHODS = ("GET", "POST", "PUT", "PATCH") diff --git a/unit_tests/sources/streams/http/test_http_client.py b/unit_tests/sources/streams/http/test_http_client.py index ea245c2fb0..7dc8054b5f 100644 --- a/unit_tests/sources/streams/http/test_http_client.py +++ b/unit_tests/sources/streams/http/test_http_client.py @@ -25,6 +25,7 @@ RequestBodyException, UserDefinedBackoffException, ) +from airbyte_cdk.sources.streams.http.http_client import MessageRepresentationAirbyteTracedErrors from airbyte_cdk.sources.streams.http.requests_native_auth import TokenAuthenticator from airbyte_cdk.utils.traced_exception import AirbyteTracedException @@ -1059,3 +1060,17 @@ def update_response(*args, **kwargs): assert mock_authenticator.access_token == "new_refreshed_token" assert returned_response == valid_response assert call_count == 2 + + +def test_deprecated_alias_message_representation_airbyte_traced_errors_is_importable(): + """Verify that the deprecated alias still resolves to AirbyteTracedException.""" + assert MessageRepresentationAirbyteTracedErrors is AirbyteTracedException + + +def test_deprecated_alias_is_catchable_as_airbyte_traced_exception(): + """Verify that exceptions raised as the alias can be caught as AirbyteTracedException.""" + with pytest.raises(AirbyteTracedException): + raise MessageRepresentationAirbyteTracedErrors( + internal_message="test", + message="test user message", + )