Skip to content

libutil: Add CompressionAlgo enum, add Suggestions to UnknownCompress…#14814

Merged
Ericson2314 merged 1 commit intomasterfrom
suggestions-compression-algo-enum
Dec 17, 2025
Merged

libutil: Add CompressionAlgo enum, add Suggestions to UnknownCompress…#14814
Ericson2314 merged 1 commit intomasterfrom
suggestions-compression-algo-enum

Conversation

@xokdvium
Copy link
Contributor

@xokdvium xokdvium commented Dec 16, 2025

…ionMethod exception

Motivation

Error messages now include suggestions like:

error: unknown compression method 'bzip'
       Did you mean one of bzip2, gzip, lzip, grzip or lrzip?

Also a bit of progress on making the compression code use less stringly typed compression type, which is good because it's easy to confuse which strings are accepted where (e.g. Content-Encoding should be able to accept x-gzip, but it shouldn't be exposed in NAR decompression and so on). An enum cleanly separates the concerns of parsing strings / handling libarchive write/read filters.

Context

Would be helpful for fixing #14324.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

using FinishSink::finish;
};

enum class CompressionAlgo { none, brotli, bzip2, compress, grzip, gzip, lrzip, lz4, lzip, lzma, lzop, xz, zstd };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enum class CompressionAlgo { none, brotli, bzip2, compress, grzip, gzip, lrzip, lz4, lzip, lzma, lzop, xz, zstd };
enum class CompressionAlgo { none, brotli, bzip2, compress, grzip, gzip, lrzip, lz4, lzip, lzma, lzop, xz, zstd, };

I like trailing comma better, then it will do one on each line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

…ionMethod exception

Error messages now include suggestions like:

error: unknown compression method 'bzip'
       Did you mean one of bzip2, gzip, lzip, grzip or lrzip?

Also a bit of progress on making the compression code use less stringly
typed compression type, which is good because it's easy to confuse
which strings are accepted where (e.g. Content-Encoding should be able
to accept x-gzip, but it shouldn't be exposed in NAR decompression and
so on). An enum cleanly separates the concerns of parsing strings / handling
libarchive write/read filters.
@xokdvium xokdvium force-pushed the suggestions-compression-algo-enum branch from c61b066 to 4060ec3 Compare December 16, 2025 23:40
@Ericson2314 Ericson2314 added this pull request to the merge queue Dec 17, 2025
Merged via the queue into master with commit 8cf8a91 Dec 17, 2025
20 checks passed
@Ericson2314 Ericson2314 deleted the suggestions-compression-algo-enum branch December 17, 2025 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants