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: check err before using file object #12

Merged

Conversation

ndibari-etsy
Copy link
Contributor

Description

This change moves the order of operations around to check if there is an error returned by downloadReleaseArchive first before using the zipFile variable. In the case that there was a problem downloading the release archive from Hashicorp this function should return the originating error and not mask it with a nil pointer dereference.

Context / Why are we making this change?

If there is an error downloading a release archive from Hashicorp, the zipFile variable will be nil and cause a panic on the deferred call to os.Remove due to a nil pointer dereference. This hides the underlying error and prevents the user from knowing what the actual problem is in downloading the release archive.

russtaylor
russtaylor previously approved these changes Jan 11, 2024
If there is an error downloading a release archive from
Hashicorp, the `zipFile` variable will be `nil` and cause
a panic on the deferred call to `os.Remove` due to a nil
pointer dereference. This hides the underlying error and
prevents the user from knowing what the actual problem is
in downloading the release archive.

This change moves the order of operations around to check
if there is an error returned by `downloadReleaseArchive`
first before using the `zipFile` variable. In the case that
there was a problem downloading the release archive from
Hashicorp this function should return the originating error
and not mask it with a nil pointer dereference.
@simpsonw simpsonw merged commit 0e5e5b8 into etsy:main Jan 16, 2024
1 check passed
@ndibari-etsy ndibari-etsy deleted the reorder_error_check_on_release_download branch January 16, 2024 18:57
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.

4 participants