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

Conversation

agarctfi
Copy link
Contributor

@agarctfi agarctfi commented Mar 4, 2025

Solves: https://github.com/airbytehq/airbyte-internal-issues/issues/11320

Updating action to retry should have no adverse effect since the stream will still fail once it exceeds the retry amounts. The retry should allow the sync to continue if it is an actual DNS error. If it is an actual URL error, the stream will fail after it exceeds the maximum retry amount.

Summary by CodeRabbit

  • Bug Fixes

    • Updated error handling for URL-related and DNS issues, so the system now retries operations instead of failing immediately.
  • Tests

    • Added comprehensive tests to confirm the new behavior, ensuring improved resilience when temporary connectivity challenges occur.

@github-actions github-actions bot added bug Something isn't working security labels Mar 4, 2025
Copy link
Contributor

coderabbitai bot commented Mar 4, 2025

📝 Walkthrough

Walkthrough

This update refines the error handling in the HTTP stream logic. The error mapping for an InvalidURL exception has been adjusted so that the response action is now to retry rather than fail, and the error is classified as transient instead of a configuration error. In addition, the error message has been updated to include DNS resolution issues. A new stub class with an error handler method and a corresponding unit test have been introduced to verify that DNS errors are handled with the new retry behavior. wdyt?

Changes

File Summary
airbyte_cdk/.../default_error_mapping.py Updated error mapping for InvalidURL by changing response_action from FAIL to RETRY, failure_type from config_error to transient_error, and refining the error_message to include DNS errors.
unit_tests/.../test_http.py Added StubHttpStreamWithErrorHandler (extending StubBasicReadHttpStream) with a get_error_handler method returning a HttpStatusErrorHandler instance, and introduced test_dns_resolution_error_retry to assert the retry behavior on DNS errors.

Sequence Diagram(s)

sequenceDiagram
    participant Stream as HTTP Stream
    participant EH as Error Handler
    participant Logger as Logger

    Note over Stream: An InvalidURL (or DNS) error occurs
    Stream->>EH: Handle InvalidURL exception
    EH-->>Stream: Return ErrorResolution(response_action=RETRY, failure_type=transient_error)
Loading
sequenceDiagram
    participant Test as Unit Test
    participant StubStream as StubHttpStreamWithErrorHandler
    participant EH as Error Handler

    Test->>StubStream: Simulate InvalidURL exception (with potential DNS error)
    StubStream->>EH: Retrieve error handler via get_error_handler()
    EH-->>StubStream: Provide ErrorResolution with RETRY and transient_error
    Test-->>Test: Assert the error resolution matches expected retry behavior
Loading

Would you like any further refinements to these diagrams? wdyt?


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fdfeef7 and 182e989.

📒 Files selected for processing (2)
  • airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py (1 hunks)
  • unit_tests/sources/streams/http/test_http.py (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (python)
🔇 Additional comments (6)
airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py (2)

22-24: LGTM! The change to retry for InvalidURL errors looks great.

The change from FAIL to RETRY and from config_error to transient_error will help handle DNS resolution issues better. This aligns well with the PR objective of facilitating continued synchronization when the error might be transient.


24-24: Good update to the error message to include DNS errors.

The error message now clearly indicates that the issue could be either an invalid URL or a DNS resolution problem, which provides better context to users. This is a helpful clarification.

unit_tests/sources/streams/http/test_http.py (4)

13-13: LGTM! Good addition of the required import.

The addition of InvalidURL from requests.exceptions is necessary for the new test.


24-27: LGTM! Good import modification.

Updating the import to include FailureType is necessary for the new test to verify the proper failure type.


338-340: LGTM! Nice implementation of the test stub class.

The StubHttpStreamWithErrorHandler class properly extends StubBasicReadHttpStream and implements the necessary method to get the error handler for testing purposes.


343-350: LGTM! Excellent test for the new behavior.

This test properly validates that DNS resolution errors (represented by InvalidURL exceptions) are now retried instead of failing immediately. The assertions confirm both the response action and failure type match the updated configuration.

The test is well-structured and focuses precisely on what changed in the error mapping.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@agarctfi agarctfi merged commit ab4a8ee into main Mar 4, 2025
24 checks passed
@agarctfi agarctfi deleted the agarctfi/fix-dns-resolution-errors branch March 4, 2025 21:46
rpopov added a commit to rpopov/airbyte-python-cdk that referenced this pull request Mar 5, 2025
* main:
  ci: add Docker build workflow for PR checks (airbytehq#385)
  fix: Update DEFAULT_ERROR_MAPPING for InvalidURL to RETRY (airbytehq#384)
  chore: use python base image 4.0.0 in SDM (airbytehq#382)
  ci: add check for 'do not merge' in PR titles (airbytehq#383)
  chore: remove embedded module (airbytehq#380)
  build: update pyarrow to ^19.0.0 (do not merge) (airbytehq#379)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant