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 nil panic #3922
prevent nil panic #3922
Conversation
Shouldn't these trigger off non-nil errors, not nil object checks? |
I'd rather check for the condition actually causing the failure in case crazy things happen. No matter what the value of the error is, if the obj is nil, it will never be castable. |
Hmm… if it's possible to return nil in a non-error case, that impl is broken. Should sweep for that if we're not confident in it, and short circuit on non-nil err here |
I don't disagree that it would be broken at a lower level. I'm just struggling to come up with a valid reason to avoid checking for the condition that will actually cause an error and handling in a reasonable way. |
I just don't like assuming the value is castable in an error condition. |
I don't like assuming I should throw away the returned value in the case of an error. This is supposed to be an object whose only purpose is to pass through to storage in a type-safe way. Assuming an error means a nil return value violates that principle. |
compromise?
|
You should not cast values if err != nil. The general go convention is "if err != nil, all other return values are suspect unless defined otherwise, and if defined otherwise, shoot the reviewer who allowed it because that's crazy talk". |
I don't like it. Waaa. [merge] |
Oh, just in case you didn't look, I did change it to |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/2884/) (Image: devenv-fedora_2101) |
Evaluated for origin merge up to 74a2d68 |
[Test]ing while waiting on the merge queue |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/3877/) |
Evaluated for origin test up to 74a2d68 |
Fixes #3529, Fixes #3959
I can't reproduce the panic, but this prevents panics in the casts.