{"record":{"id":"d76286c6db732ad1","repo":"thanos-io/thanos","slug":"expand-environment-variables","errorCode":null,"errorMessage":"expand environment variables","messagePattern":"expand environment variables","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/reloader/reloader.go","lineNumber":383,"sourceCode":"\t}\n\n\t// Detect and extract gzipped file.\n\tif bytes.Equal(b[0:3], firstGzipBytes) {\n\t\tzr, err := gzip.NewReader(bytes.NewReader(b))\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"create gzip reader\")\n\t\t}\n\t\tdefer runutil.CloseWithLogOnErr(r.logger, zr, \"gzip reader close\")\n\n\t\tb, err = io.ReadAll(zr)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"read compressed config file\")\n\t\t}\n\t}\n\n\tb, err = r.expandEnv(b)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"expand environment variables\")\n\t}\n\n\ttmpFile := outputFile + \".tmp\"\n\tdefer func() {\n\t\t_ = os.Remove(tmpFile)\n\t}()\n\tif err := os.WriteFile(tmpFile, b, 0644); err != nil {\n\t\treturn errors.Wrap(err, \"write file\")\n\t}\n\tif err := os.Rename(tmpFile, outputFile); err != nil {\n\t\treturn errors.Wrap(err, \"rename file\")\n\t}\n\treturn nil\n}\n\n// apply triggers Prometheus reload if rules or config changed. If cfgOutputFile is set, we also\n// expand env vars into config file before reloading.\n// Reload is retried in retryInterval until watchInterval.","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/reloader/reloader.go#L365-L401","documentation":"Wraps r.expandEnv in Reloader.normalize: expanding environment variables in the config failed, typically an unbalanced ${VAR or other os.Expand syntax problem introduced by a malformed ${...} template in the config.","triggerScenarios":"Thrown at pkg/reloader/reloader.go:383 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define all referenced environment variables in the pod/secret.","Check for typos or unsupported syntax in ${VAR} placeholders.","Inspect the wrapped error for the offending variable."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}