{"record":{"id":"b768003dc0d9b3ae","repo":"grafana/k6","slug":"w-metric-q-has-unmatched-opening-close-curly-br","errorCode":null,"errorMessage":"%w, metric %q has unmatched opening/close curly brace","messagePattern":"%w, metric %q has unmatched opening/close curly brace","errorType":"validation","errorClass":"ErrMetricNameParsing","httpStatus":null,"severity":"error","filePath":"metrics/metric.go","lineNumber":106,"sourceCode":"// Its first return value is the parsed metric name, second are parsed tags as as slice\n// of \"key:value\" strings. On failure, it returns an error containing the `ErrMetricNameParsing` in its chain.\nfunc ParseMetricName(name string) (string, []string, error) {\n\topeningTokenPos := strings.IndexByte(name, '{')\n\tclosingTokenPos := strings.LastIndexByte(name, '}')\n\tcontainsOpeningToken := openingTokenPos != -1\n\tcontainsClosingToken := closingTokenPos != -1\n\n\t// Neither the opening '{' token nor the closing '}' token\n\t// are present, thus the metric name only consists of a literal.\n\tif !containsOpeningToken && !containsClosingToken {\n\t\treturn name, nil, nil\n\t}\n\n\t// If the name contains an opening or closing token, but not\n\t// its counterpart, the expression is malformed.\n\tif (containsOpeningToken && !containsClosingToken) ||\n\t\t(!containsOpeningToken && containsClosingToken) {\n\t\treturn \"\", nil, fmt.Errorf(\n\t\t\t\"%w, metric %q has unmatched opening/close curly brace\",\n\t\t\tErrMetricNameParsing, name,\n\t\t)\n\t}\n\n\t// If the closing brace token appears before the opening one,\n\t// the expression is malformed\n\tif closingTokenPos < openingTokenPos {\n\t\treturn \"\", nil, fmt.Errorf(\"%w, metric %q closing curly brace appears before opening one\", ErrMetricNameParsing, name)\n\t}\n\n\t// If the last character is not a closing brace token,\n\t// the expression is malformed.\n\tif closingTokenPos != (len(name) - 1) {\n\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,","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/metrics/metric.go#L88-L124","documentation":"Raised by ParseMetricName when a metric name with tag filters contains only one of the '{' or '}' brace tokens, so the expression cannot be split into metric name and tag list. Wraps the ErrMetricNameParsing sentinel for use with errors.Is.","triggerScenarios":"Thrown at metrics/metric.go:106 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Balance the braces, e.g. http_req_duration{status:200}","Remove stray '{' or '}' characters from the metric name"],"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-14T00:17:10.932Z"}