{"record":{"id":"4590bf9973e04289","repo":"thanos-io/thanos","slug":"write-file","errorCode":null,"errorMessage":"write file","messagePattern":"write file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/reloader/reloader.go","lineNumber":391,"sourceCode":"\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.\nfunc (r *Reloader) apply(ctx context.Context) error {\n\tvar (\n\t\tcfgHash         []byte\n\t\twatchedDirsHash []byte\n\t)\n\n\tif r.cfgFile != \"\" {\n\t\th := sha256.New()","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/reloader/reloader.go#L373-L409","documentation":"Wraps os.WriteFile of the .tmp staging file in Reloader.normalize: the normalized config could not be written next to the output path (permissions, full disk). Atomic replacement of the output file cannot proceed, so the reload cycle fails and retries.","triggerScenarios":"Thrown at pkg/reloader/reloader.go:391 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the output directory exists and is writable.","Free disk space if full.","Verify the cfg-output-file flag points to a valid path."],"exampleFix":null,"handlingStrategy":"try-catch","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"}