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

Wrap url.Error in APIError #722

Merged
merged 2 commits into from
Nov 30, 2023
Merged

Wrap url.Error in APIError #722

merged 2 commits into from
Nov 30, 2023

Conversation

mgyucht
Copy link
Contributor

@mgyucht mgyucht commented Nov 30, 2023

Changes

b0f3c83 introduced a regression in the handling of errors returned from HttpClient.Do. Previously, only some errors returned by Client.Do() were retried; now, all are retried. This PR adds default error handling logic in httpclient for errors returned by Client.Do() matching the previous behavior. As part of this, we remove the duplicated transient error messages between apierr and the default client.

Tests

  • make test passing
  • make fmt applied
  • relevant integration tests applied

@mgyucht mgyucht requested a review from pietern November 30, 2023 10:22
@codecov-commenter
Copy link

codecov-commenter commented Nov 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (379b6e9) 16.85% compared to head (18cd5d0) 16.81%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #722      +/-   ##
==========================================
- Coverage   16.85%   16.81%   -0.05%     
==========================================
  Files         103      103              
  Lines       14109    14116       +7     
==========================================
- Hits         2378     2373       -5     
- Misses      11525    11535      +10     
- Partials      206      208       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

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

Discussed in person and decided on treating url.Error retries separately from apierr.APIError retries, given the former are for lower level networking issues and the latter for when we actually got a response from the server.

@mgyucht mgyucht requested a review from pietern November 30, 2023 14:38
httpclient/api_client_test.go Show resolved Hide resolved
@@ -65,16 +65,6 @@ func New(cfg *config.Config) (*DatabricksClient, error) {
},
TransientErrors: []string{
"REQUEST_LIMIT_EXCEEDED", // This is temporary workaround for SCIM API returning 500. Remove when it's fixed
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this sole example remaining, the field could be removed and folded into ErrorRetriable as well. In this case in the set of transient errors in apierr because it is SCIM related (can be another PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I will do that in another PR. I guess this is slightly more generic since it doesn't assume a specific structure of the response body, but I think it would still be OK to move to APIError.

@mgyucht mgyucht added this pull request to the merge queue Nov 30, 2023
Merged via the queue into main with commit 89952ab Nov 30, 2023
4 checks passed
@mgyucht mgyucht deleted the wrap-url-Error-as-before branch November 30, 2023 15:14
mgyucht added a commit that referenced this pull request Nov 30, 2023
Minor changes:
* Support overriding DatabricksEnvironment ([#723](#723)).
* Detect `Accept` header in `httpclient.WithResponseUnmarshal` ([#710](#710)).
* Detect `Content-Type` header in `newRequestBody` for `httpclient` ([#711](#711)).

Bug fixes:
* Retry request on `REQUEST_LIMIT_EXCEEDED` error returned by the SCIM API ([#721](#721)).
* Match retry logic of pre-refactor SDK ([#722](#722)).
@mgyucht mgyucht mentioned this pull request Nov 30, 2023
github-merge-queue bot pushed a commit that referenced this pull request Nov 30, 2023
Minor changes:
* Support overriding DatabricksEnvironment
([#723](#723)).
* Detect `Accept` header in `httpclient.WithResponseUnmarshal`
([#710](#710)).
* Detect `Content-Type` header in `newRequestBody` for `httpclient`
([#711](#711)).

Bug fixes:
* Retry request on `REQUEST_LIMIT_EXCEEDED` error returned by the SCIM
API ([#721](#721)).
* Match retry logic of pre-refactor SDK
([#722](#722)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants