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
- Supply the checks object: `k6.check(res, { 'status is 200': (r) => r.status === 200 })`
- When checks are dynamic, default to an empty object and populate it: `k6.check(res, checks || {})` — or skip the call if empty
- 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
- Always pass the checks object literal as the second argument
- Default dynamic checks: k6.check(res, checks || {}) or skip the call when empty
- Build checks objects in one place and assert they are non-empty before use
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
- group() requires a callback as a second argument
- exported 'setup' must be a function
- exported 'teardown' must be a function
- no exported functions in script
- open() can't be used with an empty filename
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/67e02b4307574f3f.
Report an issue: GitHub.