{"record":{"id":"382baa873c2aa20d","repo":"grafana/k6","slug":"invalid-value-for-metric-metadata-s-only-strin-382baa","errorCode":null,"errorMessage":"invalid value for metric metadata '%s': only String, Boolean and Number types are accepted as a metric metadata value","messagePattern":"invalid value for metric metadata '(.+?)': only String, Boolean and Number types are accepted as a metric metadata value","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/execution/execution.go","lineNumber":431,"sourceCode":"\tstate   *lib.State\n}\n\n// Get a property value for the key. May return nil if the property does not exist.\nfunc (o *metadataDynamicObject) Get(key string) sobek.Value {\n\ttcv := o.state.Tags.GetCurrentValues()\n\tif metadatum, ok := tcv.Metadata[key]; ok {\n\t\treturn o.runtime.ToValue(metadatum)\n\t}\n\treturn nil\n}\n\n// Set a property value for the key. It returns true if successful. String, Boolean\n// and Number types are implicitly converted to the Sobek's relative string\n// representation. An exception is raised in case a denied type is provided.\nfunc (o *metadataDynamicObject) Set(key string, val sobek.Value) bool {\n\to.state.Tags.Modify(func(tagsAndMeta *metrics.TagsAndMeta) {\n\t\tif err := common.ApplyCustomUserMetadata(tagsAndMeta, key, val); err != nil {\n\t\t\tpanic(o.runtime.NewTypeError(err.Error()))\n\t\t}\n\t})\n\treturn true\n}\n\n// Has returns true if the property exists.\nfunc (o *metadataDynamicObject) Has(key string) bool {\n\tctv := o.state.Tags.GetCurrentValues()\n\tif _, ok := ctv.Metadata[key]; ok {\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Delete deletes the property for the key. It returns true on success (note,\n// that includes missing property).\nfunc (o *metadataDynamicObject) Delete(key string) bool {\n\to.state.Tags.Modify(func(tagsAndMeta *metrics.TagsAndMeta) {","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/execution/execution.go#L413-L449","documentation":"metadataDynamicObject.Set (backing execution.vu.metadata[key]=value) received a value that cannot be stored as metric metadata: only String, Boolean and Number types are accepted. Any other type (object, null, undefined, symbol, function) triggers an exception in the JS runtime at assignment time.","triggerScenarios":"Thrown at internal/js/modules/k6/execution/execution.go:431 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Assign only strings, booleans, or numbers to execution.vu.metadata entries","Stringify complex values before assignment (e.g. String(obj) or JSON.stringify)","Avoid null/undefined metadata values"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}