{"record":{"id":"5e3575f30a816904","repo":"grafana/k6","slug":"w-metric-q-tag-expression-is-malformed","errorCode":null,"errorMessage":"%w, metric %q tag expression is malformed","messagePattern":"%w, metric %q tag expression is malformed","errorType":"validation","errorClass":"ErrMetricNameParsing","httpStatus":null,"severity":"error","filePath":"metrics/metric.go","lineNumber":139,"sourceCode":"\t\terr := fmt.Errorf(\n\t\t\t\"%w, metric %q lacks a closing curly brace in its last position\",\n\t\t\tErrMetricNameParsing,\n\t\t\tname,\n\t\t)\n\t\treturn \"\", nil, err\n\t}\n\n\t// We already know the position of the opening and closing curly brace\n\t// tokens. Thus, we extract the string in between them, and split its\n\t// content to obtain the tags key values.\n\ttags := strings.Split(name[openingTokenPos+1:closingTokenPos], \",\")\n\n\t// For each tag definition, ensure it is correctly formed\n\tfor i, t := range tags {\n\t\t_, value, _ := strings.Cut(t, \":\")\n\n\t\tif value == \"\" {\n\t\t\treturn \"\", nil, fmt.Errorf(\"%w, metric %q tag expression is malformed\", ErrMetricNameParsing, t)\n\t\t}\n\n\t\ttags[i] = strings.TrimSpace(t)\n\t}\n\n\treturn name[0:openingTokenPos], tags, nil\n}\n","sourceCodeStart":121,"sourceCodeEnd":147,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/metrics/metric.go#L121-L147","documentation":"Raised by ParseMetricName while splitting the brace contents of a tagged metric name: one comma-separated entry has no ':value' part (empty value after Cut), e.g. my_metric{status}. Wraps the ErrMetricNameParsing sentinel.","triggerScenarios":"Thrown at metrics/metric.go:139 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Write each tag as key:value, e.g. my_metric{status:200,method:GET}","Remove empty entries caused by trailing commas"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}