Skip to content

fix(validation): remove unreachable limit refine branches in search schemas - #1622

Open
ygd58 wants to merge 1 commit into
supermemoryai:mainfrom
ygd58:fix/search-limit-schema-dead-code
Open

fix(validation): remove unreachable limit refine branches in search schemas#1622
ygd58 wants to merge 1 commit into
supermemoryai:mainfrom
ygd58:fix/search-limit-schema-dead-code

Conversation

@ygd58

@ygd58 ygd58 commented Aug 30, 2026

Copy link
Copy Markdown

SearchRequestSchema and Searchv4RequestSchema both chain .positive().optional().default(10) before their limit refine, so by the time the refine runs the value can never be undefined (default() substitutes 10) and can never be <= 0 (positive() already rejects it). The v === undefined || (v > 0 && ...) guard was therefore dead code — only the upper bound (v <= 100) check had any effect.

Simplified both to just the meaningful check, and extended the existing source-level dead-code test (which already covered the threshold fields) plus added tests for the limit default, accepted range, and both still-rejected boundaries (0 and 101).

No behavior change — same values accepted/rejected before and after, confirmed by tests.

Refs #1205

…chemas

SearchRequestSchema and Searchv4RequestSchema both chain
.positive().optional().default(10) before their limit refine, so
by the time the refine runs the value can never be undefined
(default() substitutes 10) and can never be <= 0 (positive()
already rejects it). The v === undefined || (v > 0 && ...) guard
was therefore dead code -- only the upper bound (v <= 100) check
had any effect. Simplified both to just the meaningful check and
added tests covering the default, the accepted range, and both
still-rejected boundaries (0 and 101), plus a source-level guard
extending the existing search-threshold dead-code check.

No behavior change: same values are accepted/rejected before and
after, confirmed by the added tests.

Refs supermemoryai#1205
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.

1 participant