grafana/k6 · error

no argument was provided to http.batch()

Error message

no argument was provided to http.batch()

What it means

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.

Source

Thrown at js/modules/k6/http/request.go:502

			Response:          resp,
		}
		results[key] = c.responseFromHTTPext(resp)
		i++
	}

	return batchReqs, results, nil
}

// Batch makes multiple simultaneous HTTP requests. The provideds reqsV should be an array of request
// objects. Batch returns an array of responses and/or error
func (c *Client) Batch(reqsV ...sobek.Value) (any, error) {
	state := c.moduleInstance.vu.State()
	if state == nil {
		return nil, ErrBatchForbiddenInInitContext
	}

	if len(reqsV) == 0 {
		return nil, fmt.Errorf("no argument was provided to http.batch()")
	} else if len(reqsV) > 1 {
		return nil, fmt.Errorf("http.batch() accepts only an array or an object of requests")
	}
	var (
		err       error
		batchReqs []httpext.BatchParsedHTTPRequest
		results   any // either []*Response or map[string]*Response
	)

	switch v := reqsV[0].Export().(type) {
	case []any:
		batchReqs, results, err = c.prepareBatchArray(v)
	case map[string]any:
		batchReqs, results, err = c.prepareBatchObject(v)
	default:
		return nil, fmt.Errorf("invalid http.batch() argument type %T", v)
	}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Pass an array of requests, e.g. http.batch(['https://a.com/', 'https://b.com/'])
  2. Or pass a named object of requests
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at js/modules/k6/http/request.go:502 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/5144dd96b07ac07f. Report an issue: GitHub.