{"record":{"id":"ac9ac07ddee071b8","repo":"thanos-io/thanos","slug":"unrecognized-label-q","errorCode":null,"errorMessage":"unrecognized label %q","messagePattern":"unrecognized label %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/config.go","lineNumber":332,"sourceCode":"\tcmd.Flag(\"alertmanagers.send-timeout\", \"Timeout for sending alerts to Alertmanager\").Default(\"10s\").\n\t\tDurationVar(&ac.alertmgrsTimeout)\n\tcmd.Flag(\"alertmanagers.sd-dns-interval\", \"Interval between DNS resolutions of Alertmanager hosts.\").\n\t\tDefault(\"30s\").DurationVar(&ac.alertmgrsDNSSDInterval)\n\tac.alertQueryURL = cmd.Flag(\"alert.query-url\", \"The external Thanos Query URL that would be set in all alerts 'Source' field\").String()\n\tcmd.Flag(\"alert.label-drop\", \"Labels by name to drop before sending to alertmanager. This allows alert to be deduplicated on replica label (repeated). Similar Prometheus alert relabelling\").\n\t\tStringsVar(&ac.alertExcludeLabels)\n\tac.alertRelabelConfigPath = extflag.RegisterPathOrContent(cmd, \"alert.relabel-config\", \"YAML file that contains alert relabelling configuration.\", extflag.WithEnvSubstitution())\n\tac.alertSourceTemplate = cmd.Flag(\"alert.query-template\", \"Template to use in alerts source field. Need only include {{.Expr}} parameter\").Default(\"/graph?g0.expr={{.Expr}}&g0.tab=1\").String()\n\n\treturn ac\n}\n\nfunc parseFlagLabels(s []string) (labels.Labels, error) {\n\tvar lset labels.ScratchBuilder\n\tfor _, l := range s {\n\t\tparts := strings.SplitN(l, \"=\", 2)\n\t\tif len(parts) != 2 {\n\t\t\treturn labels.EmptyLabels(), errors.Errorf(\"unrecognized label %q\", l)\n\t\t}\n\t\tif !model.UTF8Validation.IsValidLabelName(parts[0]) {\n\t\t\treturn labels.EmptyLabels(), errors.Errorf(\"unsupported format for label %s\", l)\n\t\t}\n\t\tval, err := strconv.Unquote(parts[1])\n\t\tif err != nil {\n\t\t\treturn labels.EmptyLabels(), errors.Wrap(err, \"unquote label value\")\n\t\t}\n\t\tlset.Add(parts[0], val)\n\t}\n\tlset.Sort()\n\treturn lset.Labels(), nil\n}\n\ntype goMemLimitConfig struct {\n\tenableAutoGoMemlimit bool\n\tmemlimitRatio        float64\n}","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/config.go#L314-L350","documentation":"parseFlagLabels parses repeated label CLI flags of the form name=value into a labels.Labels set. This error is returned when an entry contains no '=' separator after SplitN(l, \"=\", 2), so it cannot be interpreted as a key/value pair. Thanos throws it to fail fast on malformed label arguments rather than silently dropping them.","triggerScenarios":"Calling parseFlagLabels (directly in tests, or via flag parsing of e.g. --label in main) with a string lacking '=', such as \"--label owner\" instead of \"--label owner=team-a\".","commonSituations":"Users pass a bare label name without a value on the command line; shell quoting/escaping drops the '='; copying docs examples with missing separator; YAML/Compose env passing truncating arguments.","solutions":["Add the '=' separator: pass --label key=value (quote the whole flag value if the shell splits it).","Check shell quoting: use --label 'key=\"value\"' so '=' and quotes survive argument splitting.","Inspect the offending label text shown in %q and re-run with the corrected entry."],"exampleFix":"// before\nthanos sidecar --label owner --label cluster=eu1\n// after\nthanos sidecar --label owner=platform --label cluster=eu1","handlingStrategy":"validation","validationCode":"func validLabelArg(l string) bool { return strings.Contains(l, \"=\") && strings.SplitN(l, \"=\", 2)[0] != \"\" }","typeGuard":null,"tryCatchPattern":"// Go: check err from parseFlagLabels/main startup\nif err := parseFlagLabels(flagLabels); err != nil {\n    return fmt.Errorf(\"bad --label flag %q: %w\", flagLabels, err)\n}","preventionTips":["Always pass labels as key=value, quoting the whole flag value in the shell.","Add a startup script lint that validates each --label entry contains '='."],"tags":["cli","config","labels"],"backgroundTag":"invalid-cli-argument","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}