Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update DEFAULT_ERROR_MAPPING for InvalidURL to RETRY #384

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
error_message="Invalid Protocol Schema: The endpoint that data is being requested from is using an invalid or insecure. Exception: requests.exceptions.InvalidSchema",
),
InvalidURL: ErrorResolution(
response_action=ResponseAction.FAIL,
failure_type=FailureType.config_error,
error_message="Invalid URL specified: The endpoint that data is being requested from is not a valid URL. Exception: requests.exceptions.InvalidURL",
response_action=ResponseAction.RETRY,
failure_type=FailureType.transient_error,
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",
),
RequestException: ErrorResolution(
response_action=ResponseAction.RETRY,
Expand Down
20 changes: 19 additions & 1 deletion unit_tests/sources/streams/http/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import pytest
import requests
from requests.exceptions import InvalidURL

from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Level, SyncMode, Type
from airbyte_cdk.sources.streams import CheckpointMixin
Expand All @@ -20,7 +21,10 @@
from airbyte_cdk.sources.streams.core import StreamData
from airbyte_cdk.sources.streams.http import HttpStream, HttpSubStream
from airbyte_cdk.sources.streams.http.error_handlers import ErrorHandler, HttpStatusErrorHandler
from airbyte_cdk.sources.streams.http.error_handlers.response_models import ResponseAction
from airbyte_cdk.sources.streams.http.error_handlers.response_models import (
FailureType,
ResponseAction,
)
from airbyte_cdk.sources.streams.http.exceptions import (
DefaultBackoffException,
RequestBodyException,
Expand Down Expand Up @@ -331,6 +335,20 @@ def test_raise_on_http_errors(mocker, error):
assert send_mock.call_count == stream.max_retries + 1


class StubHttpStreamWithErrorHandler(StubBasicReadHttpStream):
def get_error_handler(self) -> Optional[ErrorHandler]:
return HttpStatusErrorHandler(logging.getLogger())


def test_dns_resolution_error_retry():
"""Test that DNS resolution errors are retried"""
stream = StubHttpStreamWithErrorHandler()
error_handler = stream.get_error_handler()
resolution = error_handler.interpret_response(InvalidURL())
assert resolution.response_action == ResponseAction.RETRY
assert resolution.failure_type == FailureType.transient_error


class PostHttpStream(StubBasicReadHttpStream):
http_method = "POST"

Expand Down
Loading