1010
1111import pytest
1212import requests
13- from requests .auth import AuthBase
1413from requests .exceptions import InvalidURL
1514
1615from airbyte_cdk .models import AirbyteLogMessage , AirbyteMessage , Level , SyncMode , Type
2928 ResponseAction ,
3029)
3130from airbyte_cdk .sources .streams .http .exceptions import (
32- DefaultBackoffException ,
3331 RequestBodyException ,
3432 UserDefinedBackoffException ,
3533)
36- from airbyte_cdk .sources .streams .http .http_client import (
37- HttpClient ,
38- MessageRepresentationAirbyteTracedErrors ,
39- )
34+ from airbyte_cdk .sources .streams .http .http_client import HttpClient
4035from airbyte_cdk .sources .streams .http .requests_native_auth import TokenAuthenticator
36+ from airbyte_cdk .utils import AirbyteTracedException
4137from airbyte_cdk .utils .airbyte_secrets_utils import update_secrets
4238
4339
@@ -190,7 +186,7 @@ def test_stub_custom_backoff_http_stream(mocker):
190186
191187 send_mock = mocker .patch .object (requests .Session , "send" , return_value = req )
192188
193- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
189+ with pytest .raises (AirbyteTracedException ):
194190 list (stream .read_records (SyncMode .full_refresh ))
195191 assert send_mock .call_count == stream .max_retries + 1
196192
@@ -251,7 +247,7 @@ def test_4xx_error_codes_http_stream(mocker, http_code):
251247 req .status_code = http_code
252248 mocker .patch .object (requests .Session , "send" , return_value = req )
253249
254- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
250+ with pytest .raises (AirbyteTracedException ):
255251 list (stream .read_records (SyncMode .full_refresh ))
256252
257253
@@ -283,7 +279,7 @@ def test_error_codes_http_stream_error_resolution_with_response_secrets_filtered
283279 mocker .patch .object (requests .Session , "send" , return_value = res )
284280
285281 # proceed
286- with pytest .raises (MessageRepresentationAirbyteTracedErrors ) as err :
282+ with pytest .raises (AirbyteTracedException ) as err :
287283 list (stream .read_records (SyncMode .full_refresh ))
288284
289285 # we expect the header secrets are obscured
@@ -308,7 +304,7 @@ def test_raise_on_http_errors_off_429(mocker):
308304
309305 mocker .patch .object (requests .Session , "send" , return_value = req )
310306 with pytest .raises (
311- MessageRepresentationAirbyteTracedErrors ,
307+ AirbyteTracedException ,
312308 match = "Exhausted available request attempts. Please see logs for more details. Exception: HTTP Status Code: 429. Error: Too many requests." ,
313309 ):
314310 stream .exit_on_rate_limit = True
@@ -323,7 +319,7 @@ def test_raise_on_http_errors_off_5xx(mocker, status_code):
323319 req .status_code = status_code
324320
325321 send_mock = mocker .patch .object (requests .Session , "send" , return_value = req )
326- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
322+ with pytest .raises (AirbyteTracedException ):
327323 list (stream .read_records (SyncMode .full_refresh ))
328324 assert send_mock .call_count == stream .max_retries + 1
329325
@@ -354,7 +350,7 @@ def test_raise_on_http_errors(mocker, error):
354350 stream = AutoFailFalseHttpStream ()
355351 send_mock = mocker .patch .object (requests .Session , "send" , side_effect = error ())
356352
357- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
353+ with pytest .raises (AirbyteTracedException ):
358354 list (stream .read_records (SyncMode .full_refresh ))
359355 assert send_mock .call_count == stream .max_retries + 1
360356
@@ -613,7 +609,7 @@ def test_send_raise_on_http_errors_logs(mocker, status_code):
613609 res .headers = {}
614610 mocker .patch .object (requests .Session , "send" , return_value = res )
615611 mocker .patch .object (stream ._http_client , "_logger" )
616- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
612+ with pytest .raises (AirbyteTracedException ):
617613 _ , response = stream ._http_client .send_request (
618614 "GET" , "https://g" , {}, exit_on_rate_limit = True
619615 )
0 commit comments