grafana/k6 · error

value %d overflows int32

Error message

value %d overflows int32

What it means

toInt32 (internal/cloudapi/provisioning/api.go:298) is the shared guard that rejects any int64 outside [-2^31, 2^31-1] before it is placed into an int32-typed SDK field (max_vus, total_duration, archive_size). This message is the root cause wrapped by the 'max_vus:', 'total_duration:', and 'archive_size:' errors from StartLocalExecution; it can also fire directly wherever toInt32 is used.

Source

Thrown at internal/cloudapi/provisioning/api.go:298

				PushPeriodSeconds: l.GetPushPeriodSeconds(),
				MessageMaxSize:    l.GetMessageMaxSize(),
				AllowedLabels:     l.GetAllowedLabels(),
			},
		},
	}

	if url := res.ArchiveUploadUrl.Get(); url != nil {
		resp.ArchiveUploadURL = url
	}

	return resp
}

// toInt32 safely converts an int64 to int32, returning an error if
// the value overflows.
func toInt32(v int64) (int32, error) {
	if v < math.MinInt32 || v > math.MaxInt32 {
		return 0, fmt.Errorf("value %d overflows int32", v)
	}
	return int32(v), nil
}

// closeResponse drains and closes an HTTP response body. It mirrors
// the v6 package's closeResponse helper.
func closeResponse(res *http.Response, rerr *error) {
	if res == nil {
		return
	}
	_, _ = io.Copy(io.Discard, res.Body)
	if err := res.Body.Close(); err != nil && *rerr == nil {
		*rerr = err
	}
}

View on GitHub (pinned to 93accf6570)

Solutions

  1. Identify which field overflowed from the wrapping prefix (max_vus / total_duration / archive_size)
  2. Correct the value's unit or magnitude at its source (options, duration computation, archive contents)
  3. Add range validation in the caller so the failure is caught with a clearer message before provisioning
Defensive patterns

Strategy: validation

Validate before calling

func checkInt32(name string, v int64) error {
	if v < math.MinInt32 || v > math.MaxInt32 {
		return fmt.Errorf("%s %d exceeds int32 range", name, v)
	}
	return nil
}
for _, c := range []struct{ n string; v int64 }{
	{"max_vus", req.MaxVUs}, {"total_duration", req.TotalDuration}, {"archive_size", req.ArchiveSize},
} {
	if err := checkInt32(c.n, c.v); err != nil {
		return err
	}
}

Type guard

func fitsInt32(v int64) bool { return v >= math.MinInt32 && v <= math.MaxInt32 }

Try / catch

if err := client.StartLocalExecution(ctx, id, req); err != nil {
	if strings.Contains(err.Error(), "overflows int32") {
		// a request field is garbage; validate before rebuilding the request
	}
	return err
}

Prevention

When it happens

Trigger: Any StartLocalExecutionRequest field whose int64 value overflows int32: absurd VU counts, durations expressed in the wrong unit, or archives over 2 GiB.

Common situations: Unit confusion in duration math, unvalidated env-var-derived VU counts, and oversized archives are the three realistic producers.

Related errors


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