Skip to content

[Core] Refuse out-of-range compression levels in Policy::validate #236

Closed

Description

@saworbit

What happens

Policy::validate doesn't check the compression level. A policy file with compression: !Zstd { level: 99 } (or level: -5000) is accepted, and spacectl create --policy-file exits 0. The compressor clamps the level to -5..=22 with a warning, but the capsule's stored policy keeps 99. Item 10 of #197 found this.

Reproduced

$ printf 'compression: !Zstd { level: 99 }\n' > z.yaml
$ spacectl create -f in.bin --policy-file z.yaml   # exit 0

Where

Policy::validate in crates/common/src/policy.rs, and adjusted_level in crates/compression/src/lib.rs.

Proposed fix

Refuse a Zstd level outside -5..=22 and an LZ4 level outside the range the compressor uses, with a PolicyError naming the level and the range. spacectl already prints PolicyErrors as invalid policy file <name>.

Acceptance

  • A policy with an out-of-range level is refused before anything is written.
  • The levels in the default policies and docs examples still pass.

Activity

  1. added
    bug
    on Nov 15, 2026
  2. saworbit commented on Nov 15, 2026

    @saworbit
    OwnerAuthor

    Fixed in 8c931d3, PR #249. Policy::validate now refuses LZ4 levels outside 1 to 16 and Zstd levels outside -5 to 22, naming the level and the range. spacectl create --policy-file fails before writing anything. The compressor's clamp reads the same ranges from common. Test fails without the check. Changelog updated. Closes when the PR merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions