{"record":{"id":"953af4413dbcb945","repo":"grafana/k6","slug":"invalid-method-type-v","errorCode":null,"errorMessage":"invalid method type '%#v'","messagePattern":"invalid method type '%#v'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"js/modules/k6/http/request.go","lineNumber":566,"sourceCode":"func (c *Client) parseBatchRequest(key any, val any) (*httpext.ParsedHTTPRequest, error) {\n\tvar (\n\t\tmethod       = http.MethodGet\n\t\tok           bool\n\t\tbody, reqURL any\n\t\tparams       sobek.Value\n\t\trt           = c.moduleInstance.vu.Runtime()\n\t)\n\n\tswitch data := val.(type) {\n\tcase []any:\n\t\t// Handling of [\"GET\", \"http://example.com/\"]\n\t\tdataLen := len(data)\n\t\tif dataLen < 2 {\n\t\t\treturn nil, fmt.Errorf(\"invalid batch request '%#v'\", data)\n\t\t}\n\t\tmethod, ok = data[0].(string)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"invalid method type '%#v'\", data[0])\n\t\t}\n\t\treqURL = data[1]\n\t\tif dataLen > 2 {\n\t\t\tbody = data[2]\n\t\t}\n\t\tif dataLen > 3 {\n\t\t\tparams = rt.ToValue(data[3])\n\t\t}\n\n\tcase map[string]any:\n\t\t// Handling of {method: \"GET\", url: \"https://test.k6.io\"}\n\t\tif _, ok := data[\"url\"]; !ok {\n\t\t\treturn nil, fmt.Errorf(\"batch request %v doesn't have a url key\", key)\n\t\t}\n\n\t\treqURL = data[\"url\"]\n\t\tbody = data[\"body\"] // It's fine if it's missing, the map lookup will return\n","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/js/modules/k6/http/request.go#L548-L584","documentation":"In an array-form batch entry like [method, url, ...], the first element was not a string, so it cannot be an HTTP method. parseBatchRequest type-asserts data[0] to string after the array-length check passed; e.g. http.batch([42, 'http://example.com']) triggers it.","triggerScenarios":"Thrown at js/modules/k6/http/request.go:566 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the first element of each array-form batch entry a string HTTP method, e.g. ['GET', 'http://example.com']","Use the object form {method: 'GET', url: '...'} where the method value is also a string"],"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"}