{"record":{"id":"66beb3672a543d9f","repo":"thanos-io/thanos","slug":"write-file-v","errorCode":null,"errorMessage":"write file %v","messagePattern":"write file (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rules/manager.go","lineNumber":376,"sourceCode":"\t\tfor _, rg := range rg.Groups {\n\t\t\tgroupsByStrategy[*rg.PartialResponseStrategy] = append(groupsByStrategy[*rg.PartialResponseStrategy], rg)\n\t\t}\n\t\tfor s, rg := range groupsByStrategy {\n\t\t\tb, err := yaml.Marshal(configGroups{Groups: rg})\n\t\t\tif err != nil {\n\t\t\t\terrs = append(errs, errors.Wrapf(err, \"%s: failed to marshal rule groups\", fn))\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Use full file name appending to work dir, so we can differentiate between different dirs and same filenames(!).\n\t\t\t// This will be also used as key for file group name.\n\t\t\tnewFn := filepath.Join(m.workDir, s.String(), fn)\n\t\t\tif err := os.MkdirAll(filepath.Dir(newFn), os.ModePerm); err != nil {\n\t\t\t\terrs.Add(errors.Wrapf(err, \"create %s\", filepath.Dir(newFn)))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err := os.WriteFile(newFn, b, os.ModePerm); err != nil {\n\t\t\t\terrs.Add(errors.Wrapf(err, \"write file %v\", newFn))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfilesByStrategy[s] = append(filesByStrategy[s], newFn)\n\t\t\truleFiles[newFn] = fn\n\t\t}\n\t}\n\n\tm.mtx.Lock()\n\tfor s, fs := range filesByStrategy {\n\t\tmgr, ok := m.mgrs[s]\n\t\tif !ok {\n\t\t\terrs.Add(errors.Errorf(\"no manager found for %v\", s))\n\t\t\tcontinue\n\t\t}\n\t\t// We add external labels in `pkg/alert.Queue`.\n\t\tif err := mgr.Update(evalInterval, fs, m.extLset, m.externalURL, nil); err != nil {\n\t\t\t// TODO(bwplotka): Prometheus logs all error details. Fix it upstream to have consistent error handling.\n\t\t\terrs.Add(errors.Wrapf(err, \"strategy %s, update rules\", s))","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/rules/manager.go#L358-L394","documentation":"Raised in Manager.Update after marshaling a strategy's rule groups to YAML: os.WriteFile fails to write the temporary rule file into workDir/<strategy>/<filename>. Typical causes are disk-full, permission denied on workDir, or a path collision; the affected strategy's rules are not updated.","triggerScenarios":"Thrown at pkg/rules/manager.go:376 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify workDir exists and the process has write permissions","Check free disk space on the volume hosting workDir","Inspect the wrapped os.WriteFile error (path, errno) for the concrete cause"],"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"}