grafana/k6 · error
unsupported argument, expected http.expectedStatuses
Error message
unsupported argument, expected http.expectedStatuses
What it means
SetResponseCallback received a non-null value that is not an expectedStatuses object. The value exported from the Sobek VM did not type-assert to *expectedStatuses — e.g. a user-supplied function or plain object was assigned to http.setResponseCallback instead of the documented expectedStatuses result or null.
Source
Thrown at js/modules/k6/http/response_callback.go:91
result.minmax = append(result.minmax, [2]int{int(minValue.ToInteger()), int(maxValue.ToInteger())})
}
}
return &result
}
// SetResponseCallback sets the responseCallback to the value provided. Supported values are
// expectedStatuses object or a `null` which means that metrics shouldn't be tagged as failed and
// `http_req_failed` should not be emitted - the behaviour previous to this
func (c *Client) SetResponseCallback(val sobek.Value) {
if val != nil && !sobek.IsNull(val) {
// This is done this way as ExportTo exports functions to empty structs without an error
if es, ok := val.Export().(*expectedStatuses); ok {
c.responseCallback = es.match
} else {
common.Throw(
c.moduleInstance.vu.Runtime(),
fmt.Errorf("unsupported argument, expected http.expectedStatuses"),
)
}
} else {
c.responseCallback = nil
}
}
View on GitHub (pinned to 01ffac6f24)
Solutions
- Pass the value returned by http.expectedStatuses(...), e.g. http.setResponseCallback(http.expectedStatuses(200-299))
- Pass null to disable the response callback and http_req_failed tagging
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at js/modules/k6/http/response_callback.go:91 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/077ac75a7d7e3314.
Report an issue: GitHub.