thanos-io/thanos · error

matching file not found

Error message

matching file not found

What it means

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.

Solutions

  1. Fix the glob pattern/path to point at existing rule files
  2. Check working directory assumptions
  3. List files to confirm the pattern matches
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cmd/thanos/tools.go:56 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/f8f4f812151ed572. Report an issue: GitHub.

Appendix: source

Thrown at cmd/thanos/tools.go:56

func registerCheckRules(app extkingpin.AppClause) {
	cmd := app.Command("rules-check", "Check if the rule files are valid or not.")
	crc := &checkRulesConfig{}
	crc.registerFlag(cmd)
	cmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error {
		// Dummy actor to immediately kill the group after the run function returns.
		g.Add(func() error { return nil }, func(error) {})
		return checkRulesFiles(logger, &crc.rulesFiles)
	})
}

func checkRulesFiles(logger log.Logger, patterns *[]string) error {
	var failed errutil.MultiError

	for _, p := range *patterns {
		level.Info(logger).Log("msg", "checking", "pattern", p)
		matches, err := filepath.Glob(p)
		if err != nil || matches == nil {
			err = errors.New("matching file not found")
			level.Error(logger).Log("result", "FAILED", "error", err)
			failed.Add(err)
			continue
		}
		for _, fn := range matches {
			level.Info(logger).Log("msg", "checking", "filename", filepath.Clean(fn))
			f, er := os.Open(fn)
			if er != nil {
				level.Error(logger).Log("result", "FAILED", "error", er)
				failed.Add(er)
				continue
			}
			defer func() { _ = f.Close() }()

			n, errs := rules.ValidateAndCount(f)
			if errs.Err() != nil {
				level.Error(logger).Log("result", "FAILED")
				for _, e := range errs {

View on GitHub (pinned to 35b8b99117)