Skip to content

fix(node): align delete segments count validation - #4961

Open
Abhishekpandey123-git wants to merge 3 commits into
apache:masterfrom
Abhishekpandey123-git:fix/4850-delete-segments-count
Open

Abhishekpandey123-git wants to merge 3 commits into
apache:masterfrom
Abhishekpandey123-git:fix/4850-delete-segments-count

Conversation

@Abhishekpandey123-git

Copy link
Copy Markdown

Summary

Fix the inconsistency between the Node SDK and server behavior for segmentsCount in DeleteSegments.

Changes

  • Remove the Node SDK upper-bound validation of 1000 for segmentsCount.
  • Fix the validation error message to reference segmentsCount.
  • Remove the outdated Rust documentation stating that the maximum value is 1000.
  • Add regression tests covering:
    • segmentsCount < 1
    • segmentsCount > 1000
    • normal serialization

Testing

  • segment.utils.test.ts — 3/3 passed
  • partition.utils.test.ts — 3/3 passed

Fixes #4850

@github-actions

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

If AI assistance was used to create this PR, you are required to run the team-review skill before opening it.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer
  • /pin - exempt the PR from the stale bot, /unpin to undo

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Nov 17, 2026
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.97%. Comparing base (793f0af) to head (2242511).
⚠️ Report is 13 commits behind head on master.

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4961      +/-   ##
============================================
+ Coverage     73.91%   77.97%   +4.06%     
  Complexity     4315     4315              
============================================
  Files          1493     1481      -12     
  Lines        224543   224066     -477     
  Branches     154530   154058     -472     
============================================
+ Hits         165975   174725    +8750     
+ Misses        53344    44030    -9314     
- Partials       5224     5311      +87     
Components Coverage Δ
Rust Core 73.62% <ø> (+5.55%) ⬆️
Java SDK 80.95% <ø> (+0.01%) ⬆️
C# SDK 85.95% <ø> (+5.28%) ⬆️
Python SDK 86.61% <ø> (+0.01%) ⬆️
PHP SDK 91.86% <ø> (ø)
Node SDK 97.24% <100.00%> (+0.08%) ⬆️
Go SDK 73.69% <ø> (+0.23%) ⬆️
C++ SDK 85.47% <ø> (ø)
Files with missing lines Coverage Δ
core/common/src/http/segments/delete_segments.rs 0.00% <ø> (ø)
foreign/node/src/wire/segment/segment.utils.ts 100.00% <100.00%> (+46.15%) ⬆️

... and 322 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@justinmclean

Copy link
Copy Markdown
Member

Thanks @Abhishekpandey123-git, and welcome.


if (segmentsCount < 1 || segmentsCount > 1000)
throw new Error('Topic partition_count must be between 1 and 1000');
if (segmentsCount < 1)

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.

warning: writeUInt32LE truncates newly accepted fractional counts above 1,000, so the server receives a different delete count. require Number.isInteger(segmentsCount) before encoding.

});

it('allow segments count > 1000', () => {
assert.doesNotThrow(

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.

warning: this test passes even if the request encodes a different count. assert the last four bytes encode 1001 in little-endian order.


it('throw on segments count < 1', () => {
assert.throws(
() => serializeSegmentsParams(2, 1, 1, 0),

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.

warning: the server accepts zero as a no-op, while this new test requires the SDK to reject it. cover the zero-count behavior in a follow-up so the SDK matches the server.

This branch has not been deployed

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

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node SDK: delete segments count limit and error message don't match the server

3 participants