twpayne/chezmoi · error

%s: unknown compression format

Error message

%s: unknown compression format

What it means

getExternalData decompresses fetched external data based on the declared compression format. When the compressionFormat value does not match any supported format (e.g. gzip, zstd), decompress returns this error instead of guessing. It indicates a bad compressionFormat value in configuration or source state.

Source

Thrown at internal/chezmoi/compression.go:51

		gzipReader, err := gzip.NewReader(bytes.NewReader(data))
		if err != nil {
			return nil, err
		}
		return io.ReadAll(gzipReader)
	case CompressionFormatXz:
		xzReader, err := xz.NewReader(bytes.NewReader(data))
		if err != nil {
			return nil, err
		}
		return io.ReadAll(xzReader)
	case CompressionFormatZstd:
		zstdReader, err := zstd.NewReader(bytes.NewReader(data))
		if err != nil {
			return nil, err
		}
		return io.ReadAll(zstdReader)
	default:
		return nil, fmt.Errorf("%s: unknown compression format", compressionFormat)
	}
}

View on GitHub (pinned to f901167e46)

Solutions

  1. Check the compressionFormat value against chezmoi's supported formats (gzip, zstd) and fix the typo
  2. Remove the compressionFormat attribute if the data is not actually compressed
  3. Upgrade chezmoi if the format is supported in a newer release

Example fix

// before
[.zshrc]
  url = "https://example.com/zshrc.zst"
  compressionFormat = "zstandard"

// after
[.zshrc]
  url = "https://example.com/zshrc.zst"
  compressionFormat = "zstd"
Defensive patterns

Strategy: validation

Validate before calling

supported := map[string]bool{"gzip": true, "zstd": true}
if cf != "" && !supported[cf] {
    return fmt.Errorf("unsupported compressionFormat %q", cf)
}

Try / catch

data, err := getExternalData(...)
if err != nil && strings.Contains(err.Error(), "unknown compression format") {
    // fall back or surface config error to user
}

Prevention

When it happens

Trigger: An external entry in .chezmoiexternal or the config sets compressionFormat to an unsupported string (typo, wrong case, or a format chezmoi does not implement).

Common situations: Typo like 'gzip' vs 'gz' or 'zstd' vs 'zst', copying a compression value from another tool, or a new format added upstream but running an older chezmoi binary.

Related errors


AI-assisted analysis of twpayne/chezmoi@f901167e46 (2026-09-01). Data as JSON: /api/errors/46d00d2c0372bc29. Report an issue: GitHub.