{"record":{"id":"077ac75a7d7e3314","repo":"grafana/k6","slug":"unsupported-argument-expected-http-expectedstatus","errorCode":null,"errorMessage":"unsupported argument, expected http.expectedStatuses","messagePattern":"unsupported argument, expected http\\.expectedStatuses","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"js/modules/k6/http/response_callback.go","lineNumber":91,"sourceCode":"\n\t\t\tresult.minmax = append(result.minmax, [2]int{int(minValue.ToInteger()), int(maxValue.ToInteger())})\n\t\t}\n\t}\n\treturn &result\n}\n\n// SetResponseCallback sets the responseCallback to the value provided. Supported values are\n// expectedStatuses object or a `null` which means that metrics shouldn't be tagged as failed and\n// `http_req_failed` should not be emitted - the behaviour previous to this\nfunc (c *Client) SetResponseCallback(val sobek.Value) {\n\tif val != nil && !sobek.IsNull(val) {\n\t\t// This is done this way as ExportTo exports functions to empty structs without an error\n\t\tif es, ok := val.Export().(*expectedStatuses); ok {\n\t\t\tc.responseCallback = es.match\n\t\t} else {\n\t\t\tcommon.Throw(\n\t\t\t\tc.moduleInstance.vu.Runtime(),\n\t\t\t\tfmt.Errorf(\"unsupported argument, expected http.expectedStatuses\"),\n\t\t\t)\n\t\t}\n\t} else {\n\t\tc.responseCallback = nil\n\t}\n}\n","sourceCodeStart":73,"sourceCodeEnd":98,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/js/modules/k6/http/response_callback.go#L73-L98","documentation":"SetResponseCallback received a non-null value that is not an expectedStatuses object. The value exported from the Sobek VM did not type-assert to *expectedStatuses — e.g. a user-supplied function or plain object was assigned to http.setResponseCallback instead of the documented expectedStatuses result or null.","triggerScenarios":"Thrown at js/modules/k6/http/response_callback.go:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the value returned by http.expectedStatuses(...), e.g. http.setResponseCallback(http.expectedStatuses(200-299))","Pass null to disable the response callback and http_req_failed tagging"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}