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

Prevent panic in ResponseError.Error() #21839

Merged
merged 2 commits into from
Oct 27, 2023

Conversation

jhendrixMSFT
Copy link
Member

@jhendrixMSFT jhendrixMSFT commented Oct 26, 2023

If RawResponse is nil (unit test scenarios), print "Missing RawResponse" instead of panicing.

Fixes #21838

If RawResponse is nil (unit test scenarios), print "nil RawResponse"
instead of panicing.
Copy link
Member

@RickWinter RickWinter left a comment

Choose a reason for hiding this comment

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

The change seems reasonable. Would guidance to users be to log and stop? We should give guidance on how to handle this case since now if it happened in production the customer needs to action

@jhendrixMSFT
Copy link
Member Author

Customers should never be making programmatic choices based on the error message string as they are subject to change. Or did I misunderstand the question?

@RickWinter
Copy link
Member

Customers should never be making programmatic choices based on the error message string as they are subject to change. Or did I misunderstand the question?

Before this change the app terminated with a panic. now it will return an error. The customer will need to do something... We should guide them on how to handle this newfound freedom.

@jhendrixMSFT
Copy link
Member Author

jhendrixMSFT commented Oct 26, 2023

SDKs only return an *azcore.ResponseError when the service returns a 400 (and possibly other) HTTP status code, which means we have a *http.Response. If a SDK method were ever to return an *azcore.ResponseError with a nil RawResponse field it means we have a bug either in an SDK or azcore.

sdk/azcore/internal/exported/response_error.go Outdated Show resolved Hide resolved
tweak string for missing RawResponse
@jhendrixMSFT jhendrixMSFT merged commit 8699613 into Azure:main Oct 27, 2023
11 checks passed
@jhendrixMSFT jhendrixMSFT deleted the azcore-responseerror branch October 27, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(&azcore.ResponseError{}).Error() panics
3 participants