Skip to content

fix: treat clampListLimit(0) as invalid and return default list limit - #638

Open
captainjoel2019-bit wants to merge 1 commit into
conduit-protocol:mainfrom
captainjoel2019-bit:fix/issue-573-bug-clamplistlimit-0-returns-0-list-limit-0
Open

fix: treat clampListLimit(0) as invalid and return default list limit#638
captainjoel2019-bit wants to merge 1 commit into
conduit-protocol:mainfrom
captainjoel2019-bit:fix/issue-573-bug-clamplistlimit-0-returns-0-list-limit-0

Conversation

@captainjoel2019-bit

Copy link
Copy Markdown

Overview

This PR fixes inconsistent behavior in clampListLimit() where a limit of 0 was treated as a valid clamp output and passed through to streams_by_sender / StreamsModule.list(). Because list({ limit: 0 }) silently returns zero streams, callers cannot distinguish an empty page from a caller bug such as an uninitialised variable or Number('') evaluation. This change treats limit <= 0 as invalid input and falls back to DEFAULT_LIST_LIMIT, so 0 no longer produces an empty stream list.

Related Issue

Fixes the reported clampListLimit(0) issue.

Changes

🐛 List-Limit Clamping Fix

  • [FIX] src/constants.ts
    • clampListLimit() now considers limit <= 0 invalid and returns DEFAULT_LIST_LIMIT.
    • Non-finite inputs (NaN, Infinity) continue to fall back to DEFAULT_LIST_LIMIT.
    • Valid limits above MAX_LIST_LIMIT are still clamped to MAX_LIST_LIMIT.
    • StreamsModule.list() no longer receives 0 as a row limit from clampListLimit().

Verification Results

npm test -- src/constants.test.ts
✅ All tests pass

Live acceptance check:
✅ clampListLimit(0) returns DEFAULT_LIST_LIMIT
✅ clampListLimit(-1) returns DEFAULT_LIST_LIMIT
✅ clampListLimit(Number.NaN) returns DEFAULT_LIST_LIMIT
✅ clampListLimit(50) returns 50
✅ clampListLimit(10000) returns MAX_LIST_LIMIT
Acceptance Criteria Status
clampListLimit(0) no longer returns 0 ✅ Returns DEFAULT_LIST_LIMIT
list({ limit: 0 }) no longer silently returns an empty stream list ✅ Default page limit used
Non-finite and non-positive inputs are handled consistently ✅ All fall back to DEFAULT_LIST_LIMIT
Existing upper-bound clamping is preserved ✅ Limits above max still clamp to MAX_LIST_LIMIT

Closes #573

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@captainjoel2019-bit Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Bug: clampListLimit(0) returns 0list({ limit: 0 }) silently returns zero streams instead of a default page

1 participant