-
Notifications
You must be signed in to change notification settings - Fork 1.2k
🐛 Conversion webhook should not panic when conversion request is nil #1970
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,12 @@ func (wh *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
return | ||
} | ||
|
||
if convertReview.Request == nil { | ||
log.Error(nil, "conversion request is nil") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be an info instead of error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Error should be used as we're logging an error message here. Also the documentation says "Info logs a non-error message with the given key/value pairs as context" so it may not be appropriate to use Info. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error seems okay to me. It definitely seems to fall in the same category as l.67 if err != nil {
log.Error(err, "failed to read conversion request")
w.WriteHeader(http.StatusBadRequest)
return
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Problem is that we're passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe log.Error(errors.New("conversion request is nil"), "failed to handle conversion request") ? Still feels a bit strange, but maybe better than logging one error as an error and the other as info There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any issue with err being Also, there are already many instances of Error being called with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We went through multiple logger iterations before we got here, but anyways, that's fine if we want to log Error |
||
w.WriteHeader(http.StatusBadRequest) | ||
return | ||
} | ||
|
||
// TODO(droot): may be move the conversion logic to a separate module to | ||
// decouple it from the http layer ? | ||
resp, err := wh.handleConvertRequest(convertReview.Request) | ||
|
Uh oh!
There was an error while loading. Please reload this page.