Skip to content

fix(clp-s): Allow reading archives with zero records (fixes #534).#2338

Open
gibber9809 wants to merge 2 commits into
y-scope:mainfrom
gibber9809:empty-file-fix
Open

fix(clp-s): Allow reading archives with zero records (fixes #534).#2338
gibber9809 wants to merge 2 commits into
y-scope:mainfrom
gibber9809:empty-file-fix

Conversation

@gibber9809

@gibber9809 gibber9809 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes a longstanding issue where clp-s refuses to decompress or search archives containing zero records. The only thing preventing this from working anymore is that ArchiveReader conservatively throws an exception whenever there are zero ERTs stored in an archive for fear of the rest of the implementation being broken when there are no ERTs. The rest of the implementation actually works fine when there are no ERTs, so the fix is to simply remove the exception thrown by ArchiveReader.

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

  • Manually tested that compressing/decompressing/searching on a completely empty file works as expected
    • Decompression correctly produces a completely empty file
    • Search for * returns no results, and fails schema matching
    • Search for $_filename: ... correctly succeeds range index matching (and subsequently fails schema matching) when the name of the empty file is specified
  • Manually tested that compressing/decompressing/searching on a file with an empty json object works as expected
    • Search for * correctly returns the empty object {}
    • Decompression correctly marshals the empty object {}

Summary by CodeRabbit

Summary by CodeRabbit

Bug Fixes

  • Fixed handling of archives that contain no schemas, which now process successfully instead of failing.

@gibber9809 gibber9809 requested a review from a team as a code owner June 18, 2026 20:37
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 330b9122-9089-451c-8594-06a9c982ef4b

📥 Commits

Reviewing files that changed from the base of the PR and between 3e8944f and c4db59e.

📒 Files selected for processing (1)
  • components/core/src/clp_s/ArchiveReader.cpp

Walkthrough

In ArchiveReader::read_metadata(), the handling for a zero-schema archive is changed: instead of throwing an OperationFailed(ErrorCodeUnsupported, ...) exception, the function now checks the metadata section reader back into the adaptor and returns success().

Changes

Empty Schema Handling in ArchiveReader

Layer / File(s) Summary
Graceful return on zero schemas in read_metadata
components/core/src/clp_s/ArchiveReader.cpp
When num_schemas == 0, the metadata section reader is checked back into the adaptor via checkin_reader_for_section(...) and success() is returned, replacing the previous ErrorCodeUnsupported exception throw.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main fix: allowing archives with zero records. It references the related issue number and directly corresponds to the primary change in the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@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: 2

🤖 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/core/src/clp_s/ArchiveReader.cpp`:
- Around line 147-149: The header documentation for the
ArchiveReader::read_metadata() method currently states that it throws when
archive metadata is empty, but the implementation now returns success when
num_schemas is zero. Update the header comment for the read_metadata() method to
accurately reflect the new behavior, removing any references to throwing
exceptions on empty schemas and clarifying that zero schemas is a valid success
condition.
- Around line 147-149: In the early return path when num_schemas equals zero,
the m_table_metadata_decompressor is never closed, leaving the decompressor
lifecycle asymmetric. Add a call to m_table_metadata_decompressor.close()
immediately before the early return statement on line 149, after the reader
checkin but before returning success, to ensure the decompressor is properly
closed and does not retain invalid or stale reader state.
🪄 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

Run ID: ff1c2005-998c-47de-a92a-0bf626441b46

📥 Commits

Reviewing files that changed from the base of the PR and between 92571fa and 3e8944f.

📒 Files selected for processing (1)
  • components/core/src/clp_s/ArchiveReader.cpp

Comment thread components/core/src/clp_s/ArchiveReader.cpp
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.

clp-s missing support for empty json objects - exits with error on decompression

1 participant