grafana/k6 · error
value must be binary
Error message
%q value must be binary
What it means
Raised in newMetadata when a metadata key ending in '-bin' (gRPC's binary-key convention) has a value that is not a []byte after export — binary-suffixed keys must carry binary data, not strings or numbers.
Solutions
- Provide binary values (e.g. k6.encoding.b64decode(...) output or byte arrays) for '-bin' keys
- Rename the key if it is not actually binary
- Ensure the value survives sobek export as a byte array
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/grpc/params.go:94 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/264abc34107ce132.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/grpc/params.go:94
if common.IsNullish(input) {
return md, nil
}
v := input.Export()
rawHeaders, ok := v.(map[string]any)
if !ok {
return md, errors.New("must be an object with key-value pairs")
}
for hk, kv := range rawHeaders {
var val string
// The gRPC spec defines that Binary-valued keys end in -bin
// https://grpc.io/docs/what-is-grpc/core-concepts/#metadata
if strings.HasSuffix(hk, "-bin") {
var binVal []byte
if binVal, ok = kv.([]byte); !ok {
return md, fmt.Errorf("%q value must be binary", hk)
}
// https://github.com/grpc/grpc-go/blob/v1.57.0/Documentation/grpc-metadata.md#storing-binary-data-in-metadata
val = string(binVal)
} else if val, ok = kv.(string); !ok {
return md, fmt.Errorf("%q value must be a string", hk)
}
md.Append(hk, val)
}
return md, nil
}
// SetSystemTags sets the system tags for the call.
func (p *callParams) SetSystemTags(state *lib.State, addr string, methodName string) {
if state.Options.SystemTags.Has(metrics.TagURL) {
p.TagsAndMeta.SetSystemTagOrMeta(metrics.TagURL, fmt.Sprintf("%s%s", addr, methodName))View on GitHub (pinned to 01ffac6f24)