grafana/k6 · error

both min and max need to be integers for argument number %d

Error message

both min and max need to be integers for argument number %d

What it means

expectedStatuses got an object argument whose min and/or max values are not integers (Number.isInteger check failed). The argument was recognized as a range object, but its bounds are fractional or non-numeric, e.g. {min: 200.5, max: '399'}.

Source

Thrown at js/modules/k6/http/response_callback.go:71

	}

	errMsg := "argument number %d to expectedStatuses was neither an integer nor an object like {min:100, max:329}"
	for i, arg := range args {
		o := arg.ToObject(rt)
		if o == nil {
			common.Throw(rt, fmt.Errorf(errMsg, i+1))
		}

		if isInt(arg) {
			result.exact = append(result.exact, int(o.ToInteger()))
		} else {
			minValue := o.Get("min")
			maxValue := o.Get("max")
			if minValue == nil || maxValue == nil {
				common.Throw(rt, fmt.Errorf(errMsg, i+1))
			}
			if !isInt(minValue) || !isInt(maxValue) {
				common.Throw(rt, fmt.Errorf("both min and max need to be integers for argument number %d", i+1))
			}

			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(

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Use whole numbers for both bounds: {min: 200, max: 299}
  2. Pass inclusive ranges as integers, e.g. http.expectedStatuses({min: 200, max: 399})
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at js/modules/k6/http/response_callback.go:71 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/34ae5471b762ab5f. Report an issue: GitHub.