{"record":{"id":"f8f4f812151ed572","repo":"thanos-io/thanos","slug":"matching-file-not-found","errorCode":null,"errorMessage":"matching file not found","messagePattern":"matching file not found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/tools.go","lineNumber":56,"sourceCode":"func registerCheckRules(app extkingpin.AppClause) {\n\tcmd := app.Command(\"rules-check\", \"Check if the rule files are valid or not.\")\n\tcrc := &checkRulesConfig{}\n\tcrc.registerFlag(cmd)\n\tcmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error {\n\t\t// Dummy actor to immediately kill the group after the run function returns.\n\t\tg.Add(func() error { return nil }, func(error) {})\n\t\treturn checkRulesFiles(logger, &crc.rulesFiles)\n\t})\n}\n\nfunc checkRulesFiles(logger log.Logger, patterns *[]string) error {\n\tvar failed errutil.MultiError\n\n\tfor _, p := range *patterns {\n\t\tlevel.Info(logger).Log(\"msg\", \"checking\", \"pattern\", p)\n\t\tmatches, err := filepath.Glob(p)\n\t\tif err != nil || matches == nil {\n\t\t\terr = errors.New(\"matching file not found\")\n\t\t\tlevel.Error(logger).Log(\"result\", \"FAILED\", \"error\", err)\n\t\t\tfailed.Add(err)\n\t\t\tcontinue\n\t\t}\n\t\tfor _, fn := range matches {\n\t\t\tlevel.Info(logger).Log(\"msg\", \"checking\", \"filename\", filepath.Clean(fn))\n\t\t\tf, er := os.Open(fn)\n\t\t\tif er != nil {\n\t\t\t\tlevel.Error(logger).Log(\"result\", \"FAILED\", \"error\", er)\n\t\t\t\tfailed.Add(er)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdefer func() { _ = f.Close() }()\n\n\t\t\tn, errs := rules.ValidateAndCount(f)\n\t\t\tif errs.Err() != nil {\n\t\t\t\tlevel.Error(logger).Log(\"result\", \"FAILED\")\n\t\t\t\tfor _, e := range errs {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/tools.go#L38-L74","documentation":"A filepath.Glob result guard in checkRulesFiles: a --rules-file pattern matched no files on disk. Since the tool's purpose is validating rule files, a pattern that selects nothing is treated as an error (likely a mistyped path) rather than silently succeeding.","triggerScenarios":"Thrown at cmd/thanos/tools.go:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the glob pattern/path to point at existing rule files","Check working directory assumptions","List files to confirm the pattern matches"],"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"}