thanos-io/thanos · error

unable to write output.

Error message

unable to write output.

What it means

Wraps the printer call that renders the metadata table to stdout after sorting. It fires when writing to standard output fails (broken pipe, closed terminal), so the computed table never reaches the user.

Solutions

  1. Ensure stdout is writable and not piped to a closed stream
  2. Retry the command with output to a file
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at cmd/thanos/tools_bucket.go:1021 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/6c3990f7972fd90b. Report an issue: GitHub.

Appendix: source

Thrown at cmd/thanos/tools_bucket.go:1021

			string(blockMeta.Thanos.Source))

		lines = append(lines, line)
	}

	var sortByColNum []int
	for _, col := range sortBy {
		index := getIndex(header, col)
		if index == -1 {
			return errors.Errorf("column %s not found", col)
		}
		sortByColNum = append(sortByColNum, index)
	}

	t := Table{Header: header, Lines: lines, SortIndices: sortByColNum}
	sort.Sort(t)
	err := printer(os.Stdout, t)
	if err != nil {
		return errors.Errorf("unable to write output.")
	}
	return nil
}

func getKeysAlphabetically(labels map[string]string) []string {
	var keys []string
	for k := range labels {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	return keys
}

// matchesSelector checks if blockMeta contains every label from
// the selector with the correct value.
func matchesSelector(blockMeta *metadata.Meta, selectorLabels labels.Labels) bool {
	matches := true
	selectorLabels.Range(func(l labels.Label) {

View on GitHub (pinned to 35b8b99117)