Skip to content

feat: reject invalid pagination request parameters - #11

Merged
DrSkillIssue merged 1 commit into
mainfrom
add-parameter-validation
Aug 21, 2026
Merged

DrSkillIssue merged 1 commit into
mainfrom
add-parameter-validation

Conversation

@DrSkillIssue

Copy link
Copy Markdown
Owner

Summary

The AspNetCore integration rejects invalid pagination request parameters with
BadHttpRequestException (status 400), which ASP.NET Core's exception handler
middleware maps to the response. The core package is unchanged and framework-agnostic.

Behavior

Input Before After
Unknown sortBy silent default order 400
sortDir outside empty/asc/desc silent ascending 400
Invalid or expired cursor unhandled ArgumentException (500) 400
pageSize zero or negative unhandled ArgumentOutOfRangeException (500) 400
ArgumentNullException from developer error thrown thrown, excluded from conversion

PaginationSortRegistry.TryResolve returns false for an unsupported direction.
Resolve keeps its fallback for consumers that want lenient semantics.

Breaking

  • Callers catching ArgumentException from the AspNetCore PaginateAsync
    overloads now receive BadHttpRequestException.
  • TryResolve returns false where an unsupported sortDir previously
    resolved ascending.

Cleanup

  • Removed unreachable null guards duplicated by lower layers.
  • Inlined single-caller private methods; [MethodImpl] hot/cold splits,
    throw helpers, and field initializers kept.
  • Updated all packages; Microsoft.CodeAnalysis.CSharp capped at 5.6.0 by the
    SDK compiler. Version bumped to 3.1.0.
  • Docs corrected in api-reference.md, patterns.md, prebuilt-definitions.md.

The AspNetCore registry entry points (Keyset(registry, request) and the
PaginateAsync overloads) throw BadHttpRequestException for an unknown
sortBy or an unsupported sortDir, and PaginateAsync converts invalid
cursors and non-positive page sizes to BadHttpRequestException.
ArgumentNullException passes through as a developer error.
PaginationSortRegistry.TryResolve returns false for an unsupported
direction; Resolve keeps its fallback.

Remove unreachable null guards, inline single-caller private methods,
update packages, and bump the version to 3.1.0.
@DrSkillIssue
DrSkillIssue merged commit 45a7a39 into main Aug 21, 2026
4 checks passed
@DrSkillIssue
DrSkillIssue deleted the add-parameter-validation branch August 21, 2026 21:38
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