-
Notifications
You must be signed in to change notification settings - Fork 557
Fix potential panics #3395
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
base: main
Are you sure you want to change the base?
Fix potential panics #3395
Conversation
At first sight, this looks like a no-no. What panic is this fixing? |
I standardized the |
Wait, I missed @pierreprinetti's comment and can't remove my approval. Please let's ensure Pierre's happy before we merge this, if possible. |
@@ -438,7 +438,7 @@ func BuildQueryString(opts any) (*url.URL, error) { | |||
return &url.URL{RawQuery: params.Encode()}, nil | |||
} | |||
// Return an error if the underlying type of 'opts' isn't a struct. | |||
return nil, fmt.Errorf("Options type is not a struct.") | |||
return &url.URL{}, fmt.Errorf("Options type is not a struct.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is surprising to see an object being built while returning an error. I think it is perfectly valid to return nil alongside a non-nil error.
I'd rather change the other functions to gracefully handle |
this was my first attempt, but I thought it will be better to cover this in core. |
Fixes potential panic, when
BuildQueryString
returns nil url.