thanos-io/thanos · error

invalid template

Error message

invalid template

What it means

Wraps template.New("").Parse(format) in the bucket inspect command: the Go text-template passed via --format is syntactically invalid (unbalanced actions, unknown functions, bad verbs), so per-block custom output cannot be rendered.

Solutions

  1. Fix Go template syntax in --format
  2. Use the default format or a known-good template
  3. Check for unbalanced {{ }} braces
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cmd/thanos/tools_bucket.go:505 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/5a107666373dbe49. Report an issue: GitHub.

Appendix: source

Thrown at cmd/thanos/tools_bucket.go:505

				if _, err = fmt.Fprintf(os.Stdout, "%s -- %s - %s Diff: %s, Compaction: %d, Downsample: %d, Source: %s\n",
					m.ULID, minTime.Format(time.RFC3339), maxTime.Format(time.RFC3339), maxTime.Sub(minTime),
					m.Compaction.Level, m.Thanos.Downsample.Resolution, m.Thanos.Source); err != nil {
					return err
				}
				return nil
			}
		case "json":
			enc := json.NewEncoder(os.Stdout)
			enc.SetIndent("", "\t")

			printBlock = func(m *metadata.Meta) error {
				return enc.Encode(&m)
			}
		default:
			tmpl, err := template.New("").Parse(format)
			if err != nil {
				return errors.Wrap(err, "invalid template")
			}
			printBlock = func(m *metadata.Meta) error {
				if err := tmpl.Execute(os.Stdout, &m); err != nil {
					return errors.Wrap(err, "execute template")
				}
				fmt.Fprintln(os.Stdout, "")
				return nil
			}
		}

		metas, _, err := fetcher.Fetch(ctx)
		if err != nil {
			return err
		}

		for _, meta := range metas {
			objects++
			if err := printBlock(meta); err != nil {

View on GitHub (pinned to 35b8b99117)