thanos-io/thanos · error

id is not a valid block ULID, got

Error message

id is not a valid block ULID, got: %v

What it means

Thrown when a block ID passed to `thanos tools bucket rewrite` fails ulid.Parse. Thanos block IDs are ULIDs (26-char, base32, e.g. 01ARZ3NDEKTSV4RRFFQ69G5FAV); any other string format is rejected before any object store access. This is an input validation guard so malformed IDs never reach the store layer.

Solutions

  1. Check each ID matches a 26-character ULID (case-sensitive, e.g. 01ARZ3NDEKTSV4RRFFQ69G5FAV) with `echo <id> | tr -d ' '` and re-run.
  2. List valid IDs with `thanos tools bucket ls --objstore.bucket=...` and copy them directly.
  3. If generating IDs in a script, avoid splitting/transforming them (no lowercase, no trimming quotes).

Example fix

// before
thanos tools bucket rewrite --objstore.bucket=b 01arz3ndektsv4rrffq69g5fav
// after
thanos tools bucket rewrite --objstore.bucket=b 01ARZ3NDEKTSV4RRFFQ69G5FAV
Defensive patterns

Strategy: validation

Validate before calling

for _, id := range strings.Split(idsFlag, ",") {
    if _, err := ulid.Parse(strings.TrimSpace(id)); err != nil {
        return fmt.Errorf("skipping invalid block id %q", id)
    }
}

Type guard

func validULID(s string) bool { _, err := ulid.Parse(s); return err == nil }

Prevention

When it happens

Trigger: Passing a non-ULID string in --block-ids / positional IDs: a truncated ID, UUID-style IDs, lowercased ULIDs, IDs with whitespace or quotes, or an empty element in a comma-separated list.

Common situations: Copy-pasting a block ID with surrounding characters from a UI or log; confusing Prometheus TSDB directory names with ULIDs; a shell script splitting a comma-separated list incorrectly producing an empty token; lowercasing IDs during shell manipulation.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at cmd/thanos/tools_bucket.go:1229

			return err
		}
		var deletions []metadata.DeletionRequest
		if len(deletionsYaml) > 0 {
			if err := yaml.Unmarshal(deletionsYaml, &deletions); err != nil {
				return err
			}
			modifiers = append(modifiers, compactv2.WithDeletionModifier(deletions...))
		}

		if len(modifiers) == 0 {
			return errors.New("rewrite configuration should be provided")
		}

		var ids []ulid.ULID
		for _, id := range tbc.blockIDs {
			u, err := ulid.Parse(id)
			if err != nil {
				return errors.Errorf("id is not a valid block ULID, got: %v", id)
			}
			ids = append(ids, u)
		}

		if err := os.RemoveAll(tbc.tmpDir); err != nil {
			return err
		}
		if err := os.MkdirAll(tbc.tmpDir, os.ModePerm); err != nil {
			return err
		}

		ctx, cancel := context.WithCancel(context.Background())
		g.Add(func() error {
			chunkPool := chunkenc.NewPool()
			changeLog := compactv2.NewChangeLog(io.Discard)
			stubCounter := promauto.With(nil).NewCounter(prometheus.CounterOpts{})
			for _, id := range ids {
				// Delete series from block & modify.

View on GitHub (pinned to 35b8b99117)