grafana/k6 · error
invalid maxSendSize value: '%#v, it needs to be a positive i
Error message
invalid maxSendSize value: '%#v, it needs to be a positive integer
What it means
After the integer check, newConnectParams rejects negative maxSendSize values (params.go:199): the send limit cannot be negative, and 0 means no limit. (The error text also has a cosmetic missing closing quote after the value.)
Source
Thrown at internal/js/modules/k6/grpc/params.go:200
result.ReflectionMetadata = md
case "maxReceiveSize":
var ok bool
result.MaxReceiveSize, ok = v.(int64)
if !ok {
return result, fmt.Errorf("invalid maxReceiveSize value: '%#v', it needs to be an integer", v)
}
if result.MaxReceiveSize < 0 {
return result, fmt.Errorf("invalid maxReceiveSize value: '%#v, it needs to be a positive integer", v)
}
case "maxSendSize":
var ok bool
result.MaxSendSize, ok = v.(int64)
if !ok {
return result, fmt.Errorf("invalid maxSendSize value: '%#v', it needs to be an integer", v)
}
if result.MaxSendSize < 0 {
return result, fmt.Errorf("invalid maxSendSize value: '%#v, it needs to be a positive integer", v)
}
case "tls":
if err := parseConnectTLSParam(result, v); err != nil {
return result, err
}
case "authority":
var ok bool
result.Authority, ok = v.(string)
if !ok {
return result, fmt.Errorf("invalid authority value: '%#v', it needs to be a string", v)
}
default:
return result, fmt.Errorf("unknown connect param: %q", k)
}
}
return result, nil
}View on GitHub (pinned to 93accf6570)
Solutions
- Use 0 for no explicit limit
- Clamp sentinel -1 values to 0 before calling connect
- Re-check the computation that produced the negative number
Example fix
// before
client.connect(addr, { maxSendSize: -1 });
// after
client.connect(addr, { maxSendSize: 0 }); // 0 = no explicit limit Defensive patterns
Strategy: validation
Validate before calling
if (connectParams.maxSendSize !== undefined) {
const n = connectParams.maxSendSize;
if (typeof n !== 'number' || !Number.isInteger(n) || n < 0) {
throw new Error(`maxSendSize must be a non-negative integer, got ${n} (use 0 for no limit)`);
}
}
client.connect(addr, connectParams); Type guard
function isByteSize(v) {
return typeof v === 'number' && Number.isInteger(v) && v >= 0;
} Prevention
- Use 0, not -1, to mean 'no explicit limit'
- Map config -1 sentinels to 0 in the config loader
- Guard computed sizes with Math.max(0, n)
When it happens
Trigger: connect(addr, { maxSendSize: -1 }) — a -1 'unlimited' or 'not set' convention leaking into the params object, or size arithmetic that underflowed.
Common situations: Configs using -1 as the 'unlimited' convention; computed limits (payload budget minus overhead) going negative for small budgets.
Related errors
- invalid maxReceiveSize value: '%#v, it needs to be a positiv
- invalid grpc.connect() parameters: %w
- invalid maxReceiveSize value: '%#v', it needs to be an integ
- invalid maxSendSize value: '%#v', it needs to be an integer
- unknown connect param: %q
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/dabdfb6f28823665.
Report an issue: GitHub.