grafana/k6 · error · TypeError
invalid value for metric tag '%s': only String, Boolean and
Error message
invalid value for metric tag '%s': only String, Boolean and Number types are accepted as a metric tag values
What it means
tagsDynamicObject.Set (backing execution.vu.tags[tag]=value) received a value that cannot be converted to a metric tag: only String, Boolean and Number are accepted. Objects, null, undefined, symbols, and functions are denied; the assignment raises an exception in the JS runtime.
Source
Thrown at internal/js/modules/k6/execution/execution.go:374
state *lib.State
}
// Get a property value for the key. May return nil if the property does not exist.
func (o *tagsDynamicObject) Get(key string) sobek.Value {
tcv := o.state.Tags.GetCurrentValues()
if tag, ok := tcv.Tags.Get(key); ok {
return o.runtime.ToValue(tag)
}
return nil
}
// Set a property value for the key. It returns true if succeed. String, Boolean
// and Number types are implicitly converted to the Sobek's relative string
// representation. An exception is raised in case a denied type is provided.
func (o *tagsDynamicObject) Set(key string, val sobek.Value) bool {
o.state.Tags.Modify(func(tagsAndMeta *metrics.TagsAndMeta) {
if err := common.ApplyCustomUserTag(tagsAndMeta, key, val); err != nil {
panic(o.runtime.NewTypeError(err.Error()))
}
})
return true
}
// Has returns true if the property exists.
func (o *tagsDynamicObject) Has(key string) bool {
ctv := o.state.Tags.GetCurrentValues()
if _, ok := ctv.Tags.Get(key); ok {
return true
}
return false
}
// Delete deletes the property for the key. It returns true on success (note,
// that includes missing property).
func (o *tagsDynamicObject) Delete(key string) bool {
o.state.Tags.Modify(func(tagsAndMeta *metrics.TagsAndMeta) {View on GitHub (pinned to 01ffac6f24)
Solutions
- Assign only strings, booleans, or numbers to execution.vu.tags entries
- Convert objects to strings explicitly (e.g. JSON.stringify or String(...)) before assigning
- Remove null/undefined assignments; clear tags via k6 API if supported
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/js/modules/k6/execution/execution.go:374 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/3345bd17819a651b.
Report an issue: GitHub.