{"record":{"id":"dd76e72d4307a6a1","repo":"VictoriaMetrics/VictoriaMetrics","slug":"unexpected-match-item-w","errorCode":null,"errorMessage":"unexpected `match` item: %w","messagePattern":"unexpected `match` item: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/promrelabel/if_expression.go","lineNumber":125,"sourceCode":"\nfunc (ie *IfExpression) unmarshalFromInterface(v any) error {\n\ties := ie.ies[:0]\n\tswitch t := v.(type) {\n\tcase string:\n\t\tieLocal, err := newIfExpression(t)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unexpected `match` option: %w\", err)\n\t\t}\n\t\ties = append(ies, ieLocal)\n\tcase []any:\n\t\tfor _, x := range t {\n\t\t\ts, ok := x.(string)\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"unexpected `match` item type; got %#v; want string\", x)\n\t\t\t}\n\t\t\tieLocal, err := newIfExpression(s)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"unexpected `match` item: %w\", err)\n\t\t\t}\n\t\t\ties = append(ies, ieLocal)\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unexpected `match` type; got %#v; want string or an array of strings\", t)\n\t}\n\tie.ies = ies\n\treturn nil\n}\n\n// MarshalYAML marshals ie to YAML\nfunc (ie *IfExpression) MarshalYAML() (any, error) {\n\tif ie == nil || len(ie.ies) == 0 {\n\t\treturn nil, nil\n\t}\n\tif len(ie.ies) == 1 {\n\t\treturn ie.ies[0].MarshalYAML()\n\t}","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/promrelabel/if_expression.go#L107-L143","documentation":"Wrapper inside IfExpression.unmarshalFromInterface when parsing an array-form `match` option: one list element failed newIfExpression (invalid series selector syntax for that item); the %w chain carries the selector parse error.","triggerScenarios":"`match` is an array of strings but at least one element is an invalid selector, e.g. `match: ['{job=\"a\"}', 'bad{']`.","commonSituations":"Copy-paste typos in one element of a multi-selector list; unbalanced braces from YAML quoting; selectors containing unescaped characters; using PromQL expressions instead of selectors in one item.","solutions":["Locate the failing item from the wrapped %w error text (it contains the parse error) and fix its syntax","Make each item a bare series selector `[name[{k=\"v\",...}]]`","Quote each item with single quotes so `{`, `}`, and `\"` survive YAML parsing","Test each selector individually with metricsql/promtool before deploying"],"exampleFix":"// before\nmatch:\n  - '{job=\"a\"}'\n  - 'job=b{'\n// after\nmatch:\n  - '{job=\"a\"}'\n  - '{job=\"b\"}'","handlingStrategy":"try-catch","validationCode":"import \"github.com/VictoriaMetrics/metricsql\"\n\nfunc validateMatchList(items []string) error {\n\tfor _, s := range items {\n\t\tif _, err := metricsql.Parse(s); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid match item %q: %w\", s, err)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := yaml.Unmarshal(data, &cfg); err != nil {\n\tif strings.Contains(err.Error(), \"unexpected `match` item\") {\n\t\treturn fmt.Errorf(\"one `match` list entry is not a valid selector: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Validate each list item is a bare series selector before deploy","Single-quote items containing braces or double quotes","Keep items on one YAML line to avoid truncation"],"tags":["promql","series-selector","config","prometheus","relabeling"],"backgroundTag":"invalid-series-selector","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}