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: backoff function error handling #98

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Conversation

paulrosca-snyk
Copy link
Contributor

@paulrosca-snyk paulrosca-snyk commented Jan 8, 2025

When calling the Backoff function of the retryablehttp client, the responses will be nil if an error occurs. This PR addresses this issue and also adds the PassthroughErrorHandler to the client in order to propagate more error details.

@@ -111,12 +111,15 @@ func GetPackageVulnerabilities(cfg *Config, purl *packageurl.PackageURL, auth *s
func getRetryClient(logger *zerolog.Logger) *http.Client {
rc := retryablehttp.NewClient()
rc.Logger = nil
rc.ErrorHandler = retryablehttp.PassthroughErrorHandler
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this needed to handle resp == nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, instead what this does is propagate the last error message to the user. i.e instead of just seeing giving up after x attempts they'll get more details

Copy link
Collaborator

Choose a reason for hiding this comment

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

nice!

@paulrosca-snyk paulrosca-snyk marked this pull request as ready for review January 9, 2025 09:29
@paulrosca-snyk paulrosca-snyk requested review from garethr and a team as code owners January 9, 2025 09:29
@paulrosca-snyk paulrosca-snyk merged commit a2115ef into main Jan 9, 2025
8 checks passed
@mcombuechen mcombuechen deleted the fix/backoff-function branch January 10, 2025 08:13
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.

2 participants