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

feat(airbyte-cdk): Have better fallback error message #43399

Merged
merged 5 commits into from
Aug 13, 2024

Conversation

maxi297
Copy link
Contributor

@maxi297 maxi297 commented Aug 8, 2024

What

Addresses https://github.com/airbytehq/airbyte-internal-issues/issues/9024

When there is an unexpected error, the error message is just The request failed due to an unknown error. We need better messages.

How

Replace DEFAULT_ERROR_RESOLUTION with a function that extracts information from the exception or the response.

Review guide

  1. airbyte-cdk/python/airbyte_cdk/sources/streams/http/error_handlers/response_models.py
  2. the rest

User Impact

On HTTP errors that the CDK does not handle, the error should have more information to debug

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

Copy link

vercel bot commented Aug 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Aug 12, 2024 6:27pm

@octavia-squidington-iii octavia-squidington-iii added the CDK Connector Development Kit label Aug 8, 2024
return f"Unexpected response with HTTP status {response.status_code}"


def create_fallback_error_resolution(response_or_exception: Union[requests.Response, Exception]) -> ErrorResolution:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the interface does not accept None like the interpret_response does. I started a conversation in our private slack. Basically:

In which case can response_or_exception be None? The typing says that it is optional but the only call where response_or_exception is not a passthrough(

error_resolution: ErrorResolution = self._error_handler.interpret_response(response if response is not None else exc)
) does not seem to pass None.

I’m asking because:

  • I’m not sure what it would mean
  • It’s another case to handle when dealing with the parameter response_or_exception
  • Most error handlers do not seem to handle which seems dangerous for AttributeError: 'NoneType' object has no attribute X

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until we figure this out, this will generate mypy issues as seen here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the Slack thread, is the proposal to modify the interpret_response() method interface to no longer be Optional[blahblah]? And that would be the solve for typing isses since interpret_response() -> create_fallback_error_resolution() will be passing the union now.

I'm not opposed to that, but are worried about all the backwards compatibility headaches? since we do have some uses of the various DefaultErrorHandlers that technically still adhere to the same interface?

Would the alternative to the mypy fix be to add a type check or None check around the calls to create_fallback_error_resolution() to guarantee it's not None, even though we're confident it never is. I didn't test myself, but I'm curious if that would make mypy stop complaining

Or the alternative alternative is just an ignore lol

Copy link
Contributor Author

@maxi297 maxi297 Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that it is a bigger change. Let's decouple the typing change from this change then. I'll just have the error message be something like "Unexpected argument while handling error." and add a comment that we expect this not to happen

@maxi297 maxi297 requested review from pnilan and brianjlai August 8, 2024 19:36
Copy link
Contributor

@brianjlai brianjlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a tiny nit on the error message, but otherwise ✅

Copy link
Contributor

@pnilan pnilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@maxi297
Copy link
Contributor Author

maxi297 commented Aug 13, 2024

/approve-regression-tests

Check job output.

✅ Approving regression tests

@maxi297 maxi297 merged commit 61c07e8 into master Aug 13, 2024
30 of 33 checks passed
@maxi297 maxi297 deleted the issue-9024/better-error-message-on-default-error branch August 13, 2024 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants