grafana/k6 · error

no checks provided to `check`

Error message

no checks provided to `check`

What it means

`k6.check(value, checks)` emits one check metric per entry of the checks object. At internal/js/modules/k6/k6.go:148 the checks argument is tested for nil — when the argument is omitted entirely, sobek passes a nil Value and k6 throws "no checks provided to `check`". A check call with no assertions has nothing to record, so k6 rejects it rather than silently passing.

Source

Thrown at internal/js/modules/k6/k6.go:153

			Metric: state.BuiltinMetrics.GroupDuration,
			Tags:   ctm.Tags,
		},
		Time:     t,
		Value:    metrics.D(t.Sub(startTime)),
		Metadata: ctm.Metadata,
	})

	return ret, err
}

// Check will emit check metrics for the provided checks.
func (mi *K6) Check(arg0, checks sobek.Value, extras ...sobek.Value) (bool, error) {
	state := mi.vu.State()
	if state == nil {
		return false, ErrCheckInInitContext
	}
	if checks == nil {
		return false, errors.New("no checks provided to `check`")
	}
	ctx := mi.vu.Context()
	rt := mi.vu.Runtime()
	t := time.Now()

	// Prepare the metric tags
	commonTagsAndMeta := state.Tags.GetCurrentValues()
	if len(extras) > 0 {
		if err := common.ApplyCustomUserTags(rt, &commonTagsAndMeta, extras[0]); err != nil {
			return false, err
		}
	}

	succ := true
	var exc error
	obj := checks.ToObject(rt)
	for _, name := range obj.Keys() {
		if strings.Contains(name, lib.GroupSeparator) {

View on GitHub (pinned to 93accf6570)

Solutions

  1. Supply the checks object: `k6.check(res, { 'status is 200': (r) => r.status === 200 })`
  2. When checks are dynamic, default to an empty object and populate it: `k6.check(res, checks || {})` — or skip the call if empty
  3. Verify the variable holding the checks object is defined

Example fix

// before
const checks = buildChecks(res); // returns undefined
k6.check(res, checks);

// after
const checks = buildChecks(res) || {};
k6.check(res, checks);
Defensive patterns

Strategy: validation

Validate before calling

const hasChecks = checks !== undefined;
if (!hasChecks) { /* skip or supply fallback */ }
if (hasChecks) k6.check(res, checks);

Try / catch

try {
  k6.check(res, checks);
} catch (e) {
  if (String(e.message).includes('no checks provided')) throw new Error('checks object was not passed to k6.check');
  throw e;
}

Prevention

When it happens

Trigger: `k6.check(res)` with the second argument missing entirely (note: this nil check only fires for an absent argument; passing undefined explicitly gets past it and iterates zero keys).

Common situations: Building checks dynamically and passing an accidentally undefined variable; refactors that drop the object; tutorials where the second argument is on a lost line.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/67e02b4307574f3f. Report an issue: GitHub.