thanos-io/thanos · error
unquote label value
Error message
unquote label value
What it means
The label value (text after the first '=') must be a valid Go quoted string; parseFlagLabels runs strconv.Unquote on it. If Unquote fails (missing surrounding quotes with escapes, or unterminated quotes), the error is wrapped as "unquote label value" and returned. This lets values contain UTF-8 escapes and quoted characters.
Solutions
- Quote the whole argument so quotes reach Thanos: --label 'key="value"' (single-quote outside, double-quote inside).
- If the value needs no escapes, pass it unquoted: --label key=value.
- Ensure escape sequences are balanced and inside quotes, e.g. --label 'key="a\nb"'.
Example fix
// before (shell strips quotes; \n then fails Unquote) thanos sidecar --label note=a\nb // after thanos sidecar --label 'note="a\nb"'
Defensive patterns
Strategy: validation
Validate before calling
func unquotableLabelValue(l string) bool {
parts := strings.SplitN(l, "=", 2)
if len(parts) != 2 { return false }
_, err := strconv.Unquote(parts[1])
return err == nil
} Try / catch
// Go
if _, err := parseFlagLabels(args); err != nil {
var unwrap interface{ Unwrap() error }
_ = unwrap // errors.Wrap adds "unquote label value" context; log full chain
} Prevention
- Use single quotes in shells so inner double quotes survive: --label 'k="v"'.
- Only quote values that actually need escapes; plain values need no quotes.
- Test the exact command line in the same shell/runtime used in production (systemd, k8s).
When it happens
Trigger: Passing --label key="value" where the shell strips the quotes so Unquote sees a bare string containing an escape sequence (e.g. key=a\nb), or a value with an unbalanced quote like key="value.
Common situations: Double-quoting confusion in shells (quotes consumed before Thanos sees them); documenting --label cluster="eu-1" literally; Windows cmd quoting differences; copy-pasted examples where quotes were part of shell syntax.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- unrecognized label
- unsupported format for label
- parse labels
- level is bigger then default set of
- unknown sync strategy
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/0d9a944bbc0e20d0.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/thanos/config.go:339
ac.alertRelabelConfigPath = extflag.RegisterPathOrContent(cmd, "alert.relabel-config", "YAML file that contains alert relabelling configuration.", extflag.WithEnvSubstitution())
ac.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()
return ac
}
func parseFlagLabels(s []string) (labels.Labels, error) {
var lset labels.ScratchBuilder
for _, l := range s {
parts := strings.SplitN(l, "=", 2)
if len(parts) != 2 {
return labels.EmptyLabels(), errors.Errorf("unrecognized label %q", l)
}
if !model.UTF8Validation.IsValidLabelName(parts[0]) {
return labels.EmptyLabels(), errors.Errorf("unsupported format for label %s", l)
}
val, err := strconv.Unquote(parts[1])
if err != nil {
return labels.EmptyLabels(), errors.Wrap(err, "unquote label value")
}
lset.Add(parts[0], val)
}
lset.Sort()
return lset.Labels(), nil
}
type goMemLimitConfig struct {
enableAutoGoMemlimit bool
memlimitRatio float64
}
func (gml *goMemLimitConfig) registerFlag(cmd extkingpin.FlagClause) *goMemLimitConfig {
cmd.Flag("enable-auto-gomemlimit",
"Enable go runtime to automatically limit memory consumption.").
Default("false").BoolVar(&gml.enableAutoGoMemlimit)
cmd.Flag("auto-gomemlimit.ratio",View on GitHub (pinned to 35b8b99117)