Skip to content

Commit d9de58b

Browse files
zeripathlafriks
andauthored
api.Context.NotFound(...) should tolerate nil (#11288)
There is an unfortunate signature change with the api.Context NotFound function; whereas the normal modules/context/Context NotFound function requires an error or nil, the api.Context variant will panic with an NPE if a nil is provided. This PR will allow api.Context.NotFound to tolerate a being passed a nil. Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent 0396fcf commit d9de58b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

modules/context/api.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ func (ctx *APIContext) NotFound(objs ...interface{}) {
212212
var message = "Not Found"
213213
var errors []string
214214
for _, obj := range objs {
215+
// Ignore nil
216+
if obj == nil {
217+
continue
218+
}
219+
215220
if err, ok := obj.(error); ok {
216221
errors = append(errors, err.Error())
217222
} else {

0 commit comments

Comments
 (0)