{"record":{"id":"ef070ccd334b7ccf","repo":"thanos-io/thanos","slug":"invalid-promoted-resource-attribute-name-q","errorCode":null,"errorMessage":"invalid promoted resource attribute name: %q","messagePattern":"invalid promoted resource attribute name: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/otlptranslator/helper.go","lineNumber":169,"sourceCode":"\t}\n\t// map ensures no duplicate label names.\n\tl := make(map[string]string, maxLabelCount)\n\tfor _, label := range labels {\n\t\tfinalKey, err := labelNamer.Build(label.Name)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"invalid label name: %q\", label.Name)\n\t\t}\n\t\tif existingValue, alreadyExists := l[finalKey]; alreadyExists {\n\t\t\tl[finalKey] = existingValue + \";\" + label.Value\n\t\t} else {\n\t\t\tl[finalKey] = label.Value\n\t\t}\n\t}\n\n\tfor _, lbl := range promotedAttrs {\n\t\tnormalized, err := labelNamer.Build(lbl.Name)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"invalid promoted resource attribute name: %q\", lbl.Name)\n\t\t}\n\t\tif _, exists := l[normalized]; !exists {\n\t\t\tl[normalized] = lbl.Value\n\t\t}\n\t}\n\n\t// Map service.name + service.namespace to job\n\tif haveServiceName {\n\t\tval := serviceName.AsString()\n\t\tif serviceNamespace, ok := resourceAttrs.Get(conventions.AttributeServiceNamespace); ok {\n\t\t\tval = fmt.Sprintf(\"%s/%s\", serviceNamespace.AsString(), val)\n\t\t}\n\t\tl[model.JobLabel] = val\n\t}\n\t// Map service.instance.id to instance\n\tif haveInstanceID {\n\t\tl[model.InstanceLabel] = instance.AsString()\n\t}","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/otlptranslator/helper.go#L151-L187","documentation":"createAttributes also promotes configured resource attributes (promotedAttrs, e.g. job/instance mapped from OTLP resource) into labels. If a promoted resource attribute name fails labelNamer.Build, this error is returned, aborting metric translation.","triggerScenarios":"Configured resource-to-label promotion attributes whose names fail label normalization — e.g. a custom promotion mapping containing a key that cannot become a valid Prometheus label name, triggered from any add*DataPoints path.","commonSituations":"Operators adding custom resource attribute promotions (via --receive.otel-promoted-attrs / collector config) with malformed key names; upstream rename of resource attributes leaving stale promotion entries.","solutions":["Fix the promoted attribute name in your promotion config to a valid Prometheus label name","Remove stale promotion entries for attributes no longer produced by the SDK","Verify each configured key matches [a-zA-Z_][a-zA-Z0-9_]* (or is properly UTF-8 enabled and normalized)","Test promotion config offline by running labelNamer.Build-equivalent sanitization on each entry"],"exampleFix":"# before (invalid promoted attr)\npromotedAttrs: [\"service.name\", \"k8s pod.name\"]\n# after\npromotedAttrs: [\"service_name\", \"k8s_pod_name\"]","handlingStrategy":"validation","validationCode":"for _, attr := range promotedAttrsConfig {\n    if !labelRe.MatchString(attr) {\n        return fmt.Errorf(\"promoted attribute %q is not a valid label name\", attr)\n    }\n}","typeGuard":"func validPromotedAttrs(attrs []string) bool {\n    for _, a := range attrs { if !labelRe.MatchString(a) { return false } }\n    return true\n}","tryCatchPattern":"attrs, err := createAttributes(...)\nif err != nil {\n    if strings.Contains(err.Error(), \"promoted resource attribute\") {\n        log.Errorf(\"bad promotion config: %v\", err)\n        return nil\n    }\n    return err\n}","preventionTips":["Validate the promotion config at startup, not per metric","Keep promoted attribute names lowercase snake_case","Remove promotions for attributes no longer emitted upstream"],"tags":["otlp","labels","resource-attributes"],"backgroundTag":"invalid-identifier-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"}