grafana/k6 · error
invalid batch request '%#v'
Error message
invalid batch request '%#v'
What it means
A batch entry used the short array form (e.g. ['GET','http://example.com/']) but has fewer than two elements, so method and URL cannot both be extracted. parseBatchRequest rejects the malformed request array.
Source
Thrown at js/modules/k6/http/request.go:562
}
return results, err
}
func (c *Client) parseBatchRequest(key any, val any) (*httpext.ParsedHTTPRequest, error) {
var (
method = http.MethodGet
ok bool
body, reqURL any
params sobek.Value
rt = c.moduleInstance.vu.Runtime()
)
switch data := val.(type) {
case []any:
// Handling of ["GET", "http://example.com/"]
dataLen := len(data)
if dataLen < 2 {
return nil, fmt.Errorf("invalid batch request '%#v'", data)
}
method, ok = data[0].(string)
if !ok {
return nil, fmt.Errorf("invalid method type '%#v'", data[0])
}
reqURL = data[1]
if dataLen > 2 {
body = data[2]
}
if dataLen > 3 {
params = rt.ToValue(data[3])
}
case map[string]any:
// Handling of {method: "GET", url: "https://test.k6.io"}
if _, ok := data["url"]; !ok {
return nil, fmt.Errorf("batch request %v doesn't have a url key", key)
}View on GitHub (pinned to 01ffac6f24)
Solutions
- Include at least method and URL in array-form entries: ['POST', 'http://example.com/', 'body']
- Or use the string shorthand: 'http://example.com/'
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at js/modules/k6/http/request.go:562 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/06ad44cd84090a48.
Report an issue: GitHub.