{"record":{"id":"dc2d5df01bba82fa","repo":"thanos-io/thanos","slug":"fn-wrapped-rule-file-read-error","errorCode":null,"errorMessage":"fn (wrapped: rule file read error)","messagePattern":"fn \\(wrapped: rule file read error\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rules/manager.go","lineNumber":351,"sourceCode":"\t}\n\n\tif err := os.RemoveAll(m.workDir); err != nil {\n\t\treturn errors.Wrapf(err, \"remove %s\", m.workDir)\n\t}\n\tif err := os.MkdirAll(m.workDir, os.ModePerm); err != nil {\n\t\treturn errors.Wrapf(err, \"create %s\", m.workDir)\n\t}\n\n\tfor _, fn := range files {\n\t\tb, err := os.ReadFile(filepath.Clean(fn))\n\t\tif err != nil {\n\t\t\terrs.Add(err)\n\t\t\tcontinue\n\t\t}\n\n\t\tvar rg configGroups\n\t\tif err := yaml.Unmarshal(b, &rg); err != nil {\n\t\t\terrs.Add(errors.Wrap(err, fn))\n\t\t\tcontinue\n\t\t}\n\n\t\t// NOTE: This is very ugly, but we need to write those yaml into tmp dir without the partial partial response field\n\t\t// which is not supported, to be able to reuse rules.Manager. The problem is that it uses yaml.UnmarshalStrict.\n\t\tgroupsByStrategy := map[storepb.PartialResponseStrategy][]configRuleAdapter{}\n\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.","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/rules/manager.go#L333-L369","documentation":"Rules manager Update fails while unmarshalling a rule file: os.ReadFile succeeded but yaml.Unmarshal of the file's contents into configGroups failed, meaning the rule file is malformed YAML. The error is added to the MultiError tagged with the file name and Update continues with the remaining files.","triggerScenarios":"Thrown at pkg/rules/manager.go:351 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the YAML syntax in the reported rule file.","Validate the file with yamllint or promtool before applying.","Check the ConfigMap/secret rendering that produced the file."],"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"}