{"record":{"id":"39dacdd85cd9150a","repo":"thanos-io/thanos","slug":"unsupported-format-for-label-s","errorCode":null,"errorMessage":"unsupported format for label %s","messagePattern":"unsupported format for label (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/config.go","lineNumber":335,"sourceCode":"\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}\n\nfunc (gml *goMemLimitConfig) registerFlag(cmd extkingpin.FlagClause) *goMemLimitConfig {\n\tcmd.Flag(\"enable-auto-gomemlimit\",","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/config.go#L317-L353","documentation":"After splitting on the first '=', parseFlagLabels validates the label name with model.UTF8Validation.IsValidLabelName. If the key part is not a valid Prometheus label name (e.g. starts with a digit, contains illegal characters, or is empty like \"=value\"), this error is returned. It guards against label names the TSDB/StoreAPI cannot accept.","triggerScenarios":"Passing a label whose key violates Prometheus label name rules: \"1abc=x\", \"my-label=x\" (hyphen), \".bad=x\", or an empty name \"=x\".","commonSituations":"Users unaware that label names must match [a-zA-Z_][a-zA-Z0-9_]* (legacy) or the stricter UTF-8 rules; using DNS hostnames with hyphens as label names; typo leaving an empty key after quoting issues.","solutions":["Rename the label to a valid name: letters/underscores first, then alphanumerics/underscores, e.g. my-label=x -> my_label=x.","Escape or replace illegal characters in the key (hyphens to underscores).","Ensure the key is non-empty: \"=x\" is invalid; supply a real label name before '='."],"exampleFix":"// before\nthanos sidecar --label cluster-name=eu1\n// after\nthanos sidecar --label cluster_name=eu1","handlingStrategy":"validation","validationCode":"import \"github.com/prometheus/common/model\"\nfunc validLabelName(l string) bool {\n    parts := strings.SplitN(l, \"=\", 2)\n    return len(parts) == 2 && model.UTF8Validation.IsValidLabelName(parts[0])\n}","typeGuard":null,"tryCatchPattern":"// Go\nif _, err := parseFlagLabels(args); err != nil {\n    if strings.HasPrefix(err.Error(), \"unsupported format for label\") {\n        // fix label name before retrying\n    }\n}","preventionTips":["Keep label names to [a-zA-Z_][a-zA-Z0-9_]* (or valid UTF-8 per current validation).","Replace hyphens/dots in hostnames or service names with underscores.","Never pass an empty key (\"=value\")."],"tags":["cli","config","labels","validation"],"backgroundTag":"invalid-argument-format","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"}