{"record":{"id":"6ea69245bcf50510","repo":"grafana/k6","slug":"argument-number-d-to-expectedstatuses-was-neither","errorCode":null,"errorMessage":"argument number %d to expectedStatuses was neither an integer nor an object like {min:100, max:329}","messagePattern":"argument number (.+?) to expectedStatuses was neither an integer nor an object like (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"js/modules/k6/http/response_callback.go","lineNumber":59,"sourceCode":"func (mi *ModuleInstance) expectedStatuses(args ...sobek.Value) *expectedStatuses {\n\trt := mi.vu.Runtime()\n\n\tif len(args) == 0 {\n\t\tcommon.Throw(rt, errors.New(\"no arguments\"))\n\t}\n\tvar result expectedStatuses\n\n\tjsIsInt, _ := sobek.AssertFunction(rt.GlobalObject().Get(\"Number\").ToObject(rt).Get(\"isInteger\"))\n\tisInt := func(a sobek.Value) bool {\n\t\tv, err := jsIsInt(sobek.Undefined(), a)\n\t\treturn err == nil && v.ToBoolean()\n\t}\n\n\terrMsg := \"argument number %d to expectedStatuses was neither an integer nor an object like {min:100, max:329}\"\n\tfor i, arg := range args {\n\t\to := arg.ToObject(rt)\n\t\tif o == nil {\n\t\t\tcommon.Throw(rt, fmt.Errorf(errMsg, i+1))\n\t\t}\n\n\t\tif isInt(arg) {\n\t\t\tresult.exact = append(result.exact, int(o.ToInteger()))\n\t\t} else {\n\t\t\tminValue := o.Get(\"min\")\n\t\t\tmaxValue := o.Get(\"max\")\n\t\t\tif minValue == nil || maxValue == nil {\n\t\t\t\tcommon.Throw(rt, fmt.Errorf(errMsg, i+1))\n\t\t\t}\n\t\t\tif !isInt(minValue) || !isInt(maxValue) {\n\t\t\t\tcommon.Throw(rt, fmt.Errorf(\"both min and max need to be integers for argument number %d\", i+1))\n\t\t\t}\n\n\t\t\tresult.minmax = append(result.minmax, [2]int{int(minValue.ToInteger()), int(maxValue.ToInteger())})\n\t\t}\n\t}\n\treturn &result","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/js/modules/k6/http/response_callback.go#L41-L77","documentation":"expectedStatuses received an argument that is neither an integer status code nor an object with min/max. The guard fires when arg.ToObject() yields nil or when the object lacks both min and max — e.g. http.expectedStatuses('200') or http.expectedStatuses({code: 200}).","triggerScenarios":"Thrown at js/modules/k6/http/response_callback.go:59 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass integers or ranges: http.expectedStatuses(200, 300-399) or http.expectedStatuses({min: 200, max: 399})","Do not pass strings or objects without min/max properties"],"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-14T00:17:10.932Z"}