{"record":{"id":"3b7f22fe20726026","repo":"thanos-io/thanos","slug":"get-content-of-relabel-configuration","errorCode":null,"errorMessage":"get content of relabel configuration","messagePattern":"get content of relabel configuration","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/receive.go","lineNumber":972,"sourceCode":"\n\tlazyRetrievalMaxBufferedResponses int\n\n\tfeatureList *[]string\n\n\theadExpandedPostingsCacheSize            uint64\n\tcompactedBlocksExpandedPostingsCacheSize uint64\n\totlpEnableTargetInfo                     bool\n\totlpResourceAttributes                   []string\n}\n\ntype relabelCfg struct {\n\t*extflag.PathOrContent\n}\n\nfunc (r *relabelCfg) RelabelConfig(supportedActions map[relabel.Action]struct{}) ([]*relabel.Config, error) {\n\trelabelContentYaml, err := r.Content()\n\tif err != nil {\n\t\treturn []*relabel.Config{}, errors.Wrap(err, \"get content of relabel configuration\")\n\t}\n\treturn block.ParseRelabelConfig(relabelContentYaml, supportedActions)\n}\n\nfunc (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {\n\trc.httpBindAddr, rc.httpGracePeriod, rc.httpTLSConfig = extkingpin.RegisterHTTPFlags(cmd)\n\trc.grpcConfig.registerFlag(cmd)\n\trc.storeRateLimits.RegisterFlags(cmd)\n\n\tcmd.Flag(\"remote-write.address\", \"Address to listen on for remote write requests.\").\n\t\tDefault(\"0.0.0.0:19291\").StringVar(&rc.rwAddress)\n\n\tcmd.Flag(\"remote-write.server-tls-cert\", \"TLS Certificate for HTTP server, leave blank to disable TLS.\").Default(\"\").StringVar(&rc.rwServerCert)\n\n\tcmd.Flag(\"remote-write.server-tls-key\", \"TLS Key for the HTTP server, leave blank to disable TLS.\").Default(\"\").StringVar(&rc.rwServerKey)\n\n\tcmd.Flag(\"remote-write.server-tls-client-ca\", \"TLS CA to verify clients against. If no client CA is specified, there is no client verification on server side. (tls.NoClientCert)\").Default(\"\").StringVar(&rc.rwServerClientCA)\n","sourceCodeStart":954,"sourceCodeEnd":990,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/receive.go#L954-L990","documentation":"The --receive.relabel-config (or default relabel config) flag is a PathOrContent; relabelCfg.Content() reads the YAML bytes from the file or inline content and this error wraps any failure to obtain that content. It fires before the YAML is even parsed, so the config is never applied and the caller gets an empty relabel config list.","triggerScenarios":"r.Content() errors because the path given to the extflag points at an unreadable/missing file, the inline content contains invalid ${VAR} expansion, or the content is empty when required.","commonSituations":"Typo in the relabel config file path; file mounted but not readable by the process user; unset env var referenced as ${VAR} in the config content; passing a directory instead of a file.","solutions":["Verify the path passed to --receive.relabel-config exists and is readable (cat the file as the running user).","Check that any ${VAR} env vars referenced in the config are set in the environment.","Confirm you are passing a file path or inline content, not a directory.","If content is embedded in a ConfigMap/Secret, ensure the mount succeeded (kubectl describe pod, check mountPropagation)."],"exampleFix":"// before\nthanos receive --receive.relabel-config=/etc/thanos/relabel.yaml  # file missing\n// after\nkubectl create configmap receive-relabel --from-file=relabel.yaml && mount it at /etc/thanos/relabel.yaml","handlingStrategy":"validation","validationCode":"import os\ndef check_relabel_config(path_or_inline):\n    if path_or_inline and os.path.exists(path_or_inline):\n        if not os.path.isfile(path_or_inline):\n            raise SystemExit(\"relabel config path is not a file\")\n        with open(path_or_inline) as f:\n            data = f.read()\n    else:\n        data = os.path.expandvars(path_or_inline or \"\")\n    if not data.strip():\n        raise SystemExit(\"relabel config content is empty\")\n    return data","typeGuard":"def is_readable_file(p):\n    try:\n        return os.path.isfile(p) and os.access(p, os.R_OK)\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":null,"preventionTips":["Always smoke-test extflag content flags with cat before rollout.","Set all ${VAR} variables referenced in configs within the container env.","Mount config files via ConfigMaps and verify mounts in readiness probes.","Do not point content flags at directories."],"tags":["config","filesystem","relabeling","startup"],"backgroundTag":"file-read-failed","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"}