{"record":{"id":"b08cfeebeaf40b18","repo":"grafana/k6","slug":"invalid-http-batch-argument-type-t","errorCode":null,"errorMessage":"invalid http.batch() argument type %T","messagePattern":"invalid http\\.batch\\(\\) argument type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"js/modules/k6/http/request.go","lineNumber":518,"sourceCode":"\n\tif len(reqsV) == 0 {\n\t\treturn nil, fmt.Errorf(\"no argument was provided to http.batch()\")\n\t} else if len(reqsV) > 1 {\n\t\treturn nil, fmt.Errorf(\"http.batch() accepts only an array or an object of requests\")\n\t}\n\tvar (\n\t\terr       error\n\t\tbatchReqs []httpext.BatchParsedHTTPRequest\n\t\tresults   any // either []*Response or map[string]*Response\n\t)\n\n\tswitch v := reqsV[0].Export().(type) {\n\tcase []any:\n\t\tbatchReqs, results, err = c.prepareBatchArray(v)\n\tcase map[string]any:\n\t\tbatchReqs, results, err = c.prepareBatchObject(v)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid http.batch() argument type %T\", v)\n\t}\n\n\tif err != nil {\n\t\tif state.Options.Throw.Bool {\n\t\t\treturn nil, err\n\t\t}\n\t\tstate.Logger.WithField(\"error\", err).Warn(\"A batch request failed\")\n\t\treturn results, nil\n\t}\n\n\treqCount := len(batchReqs)\n\terrs := httpext.MakeBatchRequests(\n\t\tc.moduleInstance.vu.Context(), state, batchReqs, reqCount,\n\t\tint(state.Options.Batch.Int64), int(state.Options.BatchPerHost.Int64),\n\t)\n\n\tfor range reqCount {\n\t\tif e := <-errs; e != nil && err == nil { // Save only the first error","sourceCodeStart":500,"sourceCodeEnd":536,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/js/modules/k6/http/request.go#L500-L536","documentation":"After Export(), the single batch argument must be []any or map[string]any; any other JS type (string, number, function...) reaches the default case. Type validation on http.batch()'s argument — only arrays and objects of request definitions are supported.","triggerScenarios":"Thrown at js/modules/k6/http/request.go:518 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an array like ['url1', ['POST','url2','body']] or an object {req1: 'url1'}","Wrap individual requests in arrays/objects rather than passing raw values"],"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"}