Skip to content

fix(compression): Match compressed-file suffixes case-insensitively (fixes #2414). - #2419

Open
junhaoliao wants to merge 10 commits into
y-scope:mainfrom
junhaoliao:feat/case-insensitive-compression-suffixes
Open

fix(compression): Match compressed-file suffixes case-insensitively (fixes #2414).#2419
junhaoliao wants to merge 10 commits into
y-scope:mainfrom
junhaoliao:feat/case-insensitive-compression-suffixes

Conversation

@junhaoliao

@junhaoliao junhaoliao commented Jul 23, 2026

Copy link
Copy Markdown
Member

Description

The Rust compression coordinator and Python FileMetadata estimated Zstandard files using non-standard .zstd and .zstandard suffixes while overlooking the standard .zst suffix.

This change updates both implementations to recognize the standard .zst extension case-insensitively and applies the same case-insensitive matching to the existing gzip suffixes. The Rust implementation uses a shared allocation-free suffix helper and does not suppress Clippy checks. Focused regression tests cover .zst, .clp.zst, .tar.zst, uppercase .ZST, and lower- and uppercase forms of every supported gzip suffix.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • task lint:fix-py (passed; the task reported existing non-blocking mypy diagnostics in unrelated Python components).
  • task lint:fix-rust (passed).
  • task tests:integration:clp-py-project-imports:
============================== 3 passed in 0.06s ===============================
  • task tests:rust-all:
     Summary [  12.606s] 36 tests run: 36 passed, 0 skipped
  • task:
#33 DONE 7.5s
  • The package smoke test could not reach compression because ./sbin/start-clp.sh failed while starting the filesystem-input package:
clp-package-0df21562-8d02-496e-b831-b1d77395659d is missing dependency log-ingestor
2026-07-23T17:59:05.831 ERROR [start_clp] Failed to start CLP.

./sbin/stop-clp.sh then removed the partially started stack successfully (stop_status=0).

Summary by CodeRabbit

  • Bug Fixes

    • Compression size estimates now recognize supported gzip and Zstandard archive extensions regardless of letter casing.
    • Gzip formats including .gz, .gzip, .tgz, and .tar.gz receive accurate uncompressed-size estimates.
    • Zstandard estimates now consistently apply to files ending in .zst, including nested archive names.
  • Tests

    • Added coverage for mixed-case extensions and supported gzip and Zstandard formats to help ensure reliable size estimates.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 04cf81fb-71ae-499e-8457-d4e7aa63530b

📥 Commits

Reviewing files that changed from the base of the PR and between 268d988 and 20522ef.

📒 Files selected for processing (1)
  • components/compression-coordinator/src/partition.rs

Walkthrough

Compressed archive size estimation now matches supported suffixes case-insensitively in Python and Rust. Zstandard detection is limited to .zst. Tests cover gzip, tar-gzip, and Zstandard filename variants.

Changes

Compressed-size estimation

Layer / File(s) Summary
Update compressed suffix estimation
components/clp-py-utils/clp_py_utils/core.py, components/compression-coordinator/src/partition.rs
Python and Rust estimation paths use case-insensitive gzip matching and recognize only .zst for Zstandard files.
Validate suffix handling
components/compression-coordinator/src/partition.rs, integration-tests/tests/test_clp_native_py_project_imports.py
Tests cover case variants of gzip, tar-gzip, and .zst filenames. The tests verify the expected size multipliers.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • y-scope/clp#2414: Restricts Zstandard detection to the .zst suffix in both estimation implementations.

Suggested reviewers: linzhihao-723

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: case-insensitive matching for compressed-file suffixes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@junhaoliao
junhaoliao requested a review from Bill-hbrhbr July 23, 2026 20:57
@junhaoliao
junhaoliao marked this pull request as ready for review July 23, 2026 20:57
@junhaoliao
junhaoliao requested a review from a team as a code owner July 23, 2026 20:57
@junhaoliao
junhaoliao requested a review from LinZhihao-723 July 23, 2026 20:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@components/compression-coordinator/src/partition.rs`:
- Around line 413-425: Expand the Zstandard suffix tests in
components/compression-coordinator/src/partition.rs lines 413-425 and
integration-tests/tests/test_clp_native_py_project_imports.py lines 28-38. Add
.zstd, .zstandard, .tar.zstd, and .tar.zstandard cases to both suites, asserting
estimate_uncompressed_size or estimated_uncompressed_size returns the original
file size rather than applying decompression expansion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: aa7e7440-002e-4679-b642-8a4b162d87d3

📥 Commits

Reviewing files that changed from the base of the PR and between c0c8676 and 6e81528.

📒 Files selected for processing (3)
  • components/clp-py-utils/clp_py_utils/core.py
  • components/compression-coordinator/src/partition.rs
  • integration-tests/tests/test_clp_native_py_project_imports.py

Comment on lines +413 to +425
#[test]
fn test_estimate_uncompressed_size_for_zstandard_suffix() {
const FILE_SIZE: u64 = 100;

for key in [
"logs/app.log.zst",
"logs/app.log.clp.zst",
"logs/app.log.tar.zst",
"logs/app.log.ZST",
] {
assert_eq!(FILE_SIZE * 8, estimate_uncompressed_size(key, FILE_SIZE));
}
}

@coderabbitai coderabbitai Bot Jul 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cover the full Zstandard suffix contract in both test suites.

Both suites verify supported .zst variants but omit the suffixes that must no longer be recognised:

  • components/compression-coordinator/src/partition.rs#L413-L425: assert .zstd, .zstandard, .tar.zstd, and .tar.zstandard return FILE_SIZE.
  • integration-tests/tests/test_clp_native_py_project_imports.py#L28-L38: add the same negative cases and assert estimated_uncompressed_size == file_size.
📍 Affects 2 files
  • components/compression-coordinator/src/partition.rs#L413-L425 (this comment)
  • integration-tests/tests/test_clp_native_py_project_imports.py#L28-L38
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/compression-coordinator/src/partition.rs` around lines 413 - 425,
Expand the Zstandard suffix tests in
components/compression-coordinator/src/partition.rs lines 413-425 and
integration-tests/tests/test_clp_native_py_project_imports.py lines 28-38. Add
.zstd, .zstandard, .tar.zstd, and .tar.zstandard cases to both suites, asserting
estimate_uncompressed_size or estimated_uncompressed_size returns the original
file size rather than applying decompression expansion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

omit the suffixes that must no longer be recognised

i'm not sure if that's a must. seems like adding such tests would also only add maintenance debt rather than actual value. what do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@junhaoliao, I think the negative cases are justified here, though I agree they should not be added merely for exhaustive extension testing.

They protect the main behavioral boundary of #2414: these suffixes were previously accepted and are now intentionally unsupported. The existing positive tests prove that .zst still works, but would not catch a later broadening back to .zstd/.zstandard—for example, if someone replaces the precise .zst check with a more permissive “zstd-like” matcher.

Since the four cases directly correspond to the removed aliases (including their .tar forms), the maintenance cost is small and the regression value is concrete. I’d keep the cases, but they can be compactly expressed as a single loop in each suite.

🐇💭

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@components/compression-coordinator/src/partition.rs`:
- Around line 241-249: Update estimate_uncompressed_size to remove the
per-object to_ascii_lowercase allocation. Add an allocation-free
ends_with_ignore_ascii_case helper using the existing suffix-length and
substring approach, then use it for each gzip suffix and the .zst check while
preserving the current compression estimates and fallback behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cc056d3f-5b68-41ff-a6f8-8766986a118f

📥 Commits

Reviewing files that changed from the base of the PR and between 6e81528 and 876e7b6.

📒 Files selected for processing (2)
  • components/clp-py-utils/clp_py_utils/core.py
  • components/compression-coordinator/src/partition.rs

Comment thread components/compression-coordinator/src/partition.rs Outdated

@LinZhihao-723 LinZhihao-723 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The issue reported in #2414 is to restrict the suffix for zstdandard to .zst. It doesn't mention case sensitivity.
@junhaoliao Why do we need case-insensitive match?

///
/// The estimated uncompressed size.
fn estimate_uncompressed_size(key: &str, size: u64) -> u64 {
fn estimate_uncompressed_size(path: &str, size: u64) -> u64 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure if using path is a good option here since the path is bucket + key.

Comment on lines +248 to +247
.any(|suffix| ends_with_ignore_ascii_case(key, suffix))
{
let path = path.to_ascii_lowercase();
if GZIP_SUFFIXES.iter().any(|suffix| path.ends_with(suffix)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please explain why you need let path = path.to_ascii_lowercase();.
Similar questions asked by 3c66a96#r3684813671.

Comment thread components/clp-py-utils/clp_py_utils/core.py
Bill-hbrhbr
Bill-hbrhbr previously approved these changes Aug 1, 2026

@Bill-hbrhbr Bill-hbrhbr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the lowercase feature is useful. It is not tracked in issue 2414 but I suppose we can update the PR title to better reflect what's being fixed and what's being added.

@Bill-hbrhbr Bill-hbrhbr linked an issue Aug 1, 2026 that may be closed by this pull request
@Bill-hbrhbr

Copy link
Copy Markdown
Contributor

For title, how about:

fix(compression-coordinator): Restrict Zstandard detection to RFC-compliant `.zst` suffixes (fixes #2414); match suffixes case-insensitively.

Comment thread components/compression-coordinator/src/partition.rs Outdated
Comment thread components/compression-coordinator/src/partition.rs
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.

Restrict Zstandard extension handling to .zst only

4 participants