{"record":{"id":"5144dd96b07ac07f","repo":"grafana/k6","slug":"no-argument-was-provided-to-http-batch","errorCode":null,"errorMessage":"no argument was provided to http.batch()","messagePattern":"no argument was provided to http\\.batch\\(\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"js/modules/k6/http/request.go","lineNumber":502,"sourceCode":"\t\t\tResponse:          resp,\n\t\t}\n\t\tresults[key] = c.responseFromHTTPext(resp)\n\t\ti++\n\t}\n\n\treturn batchReqs, results, nil\n}\n\n// Batch makes multiple simultaneous HTTP requests. The provideds reqsV should be an array of request\n// objects. Batch returns an array of responses and/or error\nfunc (c *Client) Batch(reqsV ...sobek.Value) (any, error) {\n\tstate := c.moduleInstance.vu.State()\n\tif state == nil {\n\t\treturn nil, ErrBatchForbiddenInInitContext\n\t}\n\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","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/js/modules/k6/http/request.go#L484-L520","documentation":"Client.Batch was invoked from JavaScript with no arguments at all (http.batch()). The wrapper requires at least one value containing the requests to batch; the init-context guard has already passed at this point, so the call is simply missing its argument list.","triggerScenarios":"Thrown at js/modules/k6/http/request.go:502 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an array of requests, e.g. http.batch(['https://a.com/', 'https://b.com/'])","Or pass a named object of requests"],"exampleFix":null,"handlingStrategy":"validation","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"}