Skip to content

Commit ab4a8ee

Browse files
authored
fix: Update DEFAULT_ERROR_MAPPING for InvalidURL to RETRY (#384)
1 parent 169a08c commit ab4a8ee

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
error_message="Invalid Protocol Schema: The endpoint that data is being requested from is using an invalid or insecure. Exception: requests.exceptions.InvalidSchema",
2020
),
2121
InvalidURL: ErrorResolution(
22-
response_action=ResponseAction.FAIL,
23-
failure_type=FailureType.config_error,
24-
error_message="Invalid URL specified: The endpoint that data is being requested from is not a valid URL. Exception: requests.exceptions.InvalidURL",
22+
response_action=ResponseAction.RETRY,
23+
failure_type=FailureType.transient_error,
24+
error_message="Invalid URL specified or DNS error occurred: The endpoint that data is being requested from is not a valid URL. Exception: requests.exceptions.InvalidURL",
2525
),
2626
RequestException: ErrorResolution(
2727
response_action=ResponseAction.RETRY,

unit_tests/sources/streams/http/test_http.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import pytest
1212
import requests
13+
from requests.exceptions import InvalidURL
1314

1415
from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Level, SyncMode, Type
1516
from airbyte_cdk.sources.streams import CheckpointMixin
@@ -20,7 +21,10 @@
2021
from airbyte_cdk.sources.streams.core import StreamData
2122
from airbyte_cdk.sources.streams.http import HttpStream, HttpSubStream
2223
from airbyte_cdk.sources.streams.http.error_handlers import ErrorHandler, HttpStatusErrorHandler
23-
from airbyte_cdk.sources.streams.http.error_handlers.response_models import ResponseAction
24+
from airbyte_cdk.sources.streams.http.error_handlers.response_models import (
25+
FailureType,
26+
ResponseAction,
27+
)
2428
from airbyte_cdk.sources.streams.http.exceptions import (
2529
DefaultBackoffException,
2630
RequestBodyException,
@@ -331,6 +335,20 @@ def test_raise_on_http_errors(mocker, error):
331335
assert send_mock.call_count == stream.max_retries + 1
332336

333337

338+
class StubHttpStreamWithErrorHandler(StubBasicReadHttpStream):
339+
def get_error_handler(self) -> Optional[ErrorHandler]:
340+
return HttpStatusErrorHandler(logging.getLogger())
341+
342+
343+
def test_dns_resolution_error_retry():
344+
"""Test that DNS resolution errors are retried"""
345+
stream = StubHttpStreamWithErrorHandler()
346+
error_handler = stream.get_error_handler()
347+
resolution = error_handler.interpret_response(InvalidURL())
348+
assert resolution.response_action == ResponseAction.RETRY
349+
assert resolution.failure_type == FailureType.transient_error
350+
351+
334352
class PostHttpStream(StubBasicReadHttpStream):
335353
http_method = "POST"
336354

0 commit comments

Comments
 (0)