grafana/k6 · error
invalid reflect value: '%#v', it needs to be boolean
Error message
invalid reflect value: '%#v', it needs to be boolean
What it means
The reflect option in client.connect(addr, { reflect: true }) enables fetching proto definitions via gRPC server reflection and must be a JS boolean (params.go:173). Strings like 'true', 1, or other types throw 'invalid reflect value'.
Source
Thrown at internal/js/modules/k6/grpc/params.go:175
switch k {
case "plaintext":
var ok bool
result.IsPlaintext, ok = v.(bool)
if !ok {
return result, fmt.Errorf("invalid plaintext value: '%#v', it needs to be boolean", v)
}
case "timeout":
var err error
result.Timeout, err = types.GetDurationValue(v)
if err != nil {
return result, fmt.Errorf("invalid timeout value: %w", err)
}
case "reflect":
var ok bool
result.UseReflectionProtocol, ok = v.(bool)
if !ok {
return result, fmt.Errorf("invalid reflect value: '%#v', it needs to be boolean", v)
}
case "reflectMetadata":
md, err := newMetadata(params.Get(k))
if err != nil {
return result, fmt.Errorf("invalid reflectMetadata param: %w", err)
}
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":View on GitHub (pinned to 93accf6570)
Solutions
- Use true/false literals
- Coerce env values: __ENV.REFLECT === 'true'
- Fix config parsing to produce booleans
Example fix
// before
client.connect(addr, { reflect: __ENV.REFLECT });
// after
client.connect(addr, { reflect: __ENV.REFLECT === 'true' }); Defensive patterns
Strategy: validation
Validate before calling
if (connectParams.reflect !== undefined && typeof connectParams.reflect !== 'boolean') {
throw new Error(`reflect must be boolean, got ${typeof connectParams.reflect}`);
}
client.connect(addr, connectParams); Type guard
function toBool(v) {
if (typeof v === 'boolean') return v;
if (typeof v === 'string') return v === 'true';
throw new Error(`expected boolean, got ${typeof v}`);
} Prevention
- Coerce env strings with === 'true' before passing
- Treat reflectMetadata as a companion field: it is only meaningful with reflect: true
- Keep feature toggles as booleans in config sources
When it happens
Trigger: connect(addr, { reflect: __ENV.REFLECT }); { reflect: 1 }; { reflect: 'yes' }.
Common situations: Env-driven feature toggles; config systems that serialize booleans as strings or integers.
Related errors
- invalid reflectMetadata param: %w
- invalid plaintext value: '%#v', it needs to be boolean
- invalid maxReceiveSize value: '%#v', it needs to be an integ
- invalid maxSendSize value: '%#v', it needs to be an integer
- invalid authority value: '%#v', it needs to be a string
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/7ca29c9ba4d5b5f7.
Report an issue: GitHub.