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

(&azcore.ResponseError{}).Error() panics #21838

Closed
jim-minter opened this issue Oct 26, 2023 · 1 comment · Fixed by #21839
Closed

(&azcore.ResponseError{}).Error() panics #21838

jim-minter opened this issue Oct 26, 2023 · 1 comment · Fixed by #21839
Assignees

Comments

@jim-minter
Copy link
Member

Bug Report

  • import path of package in question: "github.com/Azure/azure-sdk-for-go/sdk/azcore"
  • SDK version: v1.8.0
  • output of go version: go version go1.21.1 linux/amd64

The expression (&azcore.ResponseError{}).Error() panics because the implementation of Error() requires multiple internal fields to be set.

The minimum instantiation of azcore.ResponseError that doesn't panic when Error() is called is something like:

(&azcore.ResponseError{
	RawResponse: &http.Response{
		Request: &http.Request{
			URL: &url.URL{},
		},
		Body: io.NopCloser(bytes.NewReader(nil)),
	},
}).Error()

This isn't something that we see is causing a production problem (although perhaps there is a minor robustness issue in the highly improbable production case that any of these fields is not set).

But, it's something that trips us up from time to time in a unit test context - when unit testing some other behavior, it's easy to inadvertently instantiate a ResponseError that will then cause a panic when Error() is called.

If only to simplify unit testing, it would be neat if (*azcore.ResponseError) Error() did not panic on a zero value &azcore.ResponseError{}.

@github-actions github-actions bot added Azure.Core Client This issue points to a problem in the data-plane of the library. needs-team-triage Workflow: This issue needs the team to triage. labels Oct 26, 2023
@jhendrixMSFT jhendrixMSFT removed Client This issue points to a problem in the data-plane of the library. needs-team-triage Workflow: This issue needs the team to triage. labels Oct 26, 2023
@jhendrixMSFT jhendrixMSFT self-assigned this Oct 26, 2023
@jhendrixMSFT
Copy link
Member

Fix will go out in azcore@v1.9.0 in November.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants