Skip to content

fix(parser)!: throw QueryKitParsingException for a bad sort direction - #163

Merged
pdevito3 merged 1 commit into
v2from
fm/qk-breaking-sort-direction
Oct 2, 2026
Merged

pdevito3 merged 1 commit into
v2from
fm/qk-breaking-sort-direction

Conversation

@pdevito3

@pdevito3 pdevito3 commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

For later consideration in a major version. Do not merge now. This PR is one of three PRs that replace #119. Each PR has one breaking change. The captain decides on each PR separately.

What breaks

An invalid sort direction throws QueryKitParsingException. On v1.14.2 and main, it throws ArgumentException. The message does not change.

Example

Input v1.14.2 and main This PR
sort Age sideways ArgumentException: Invalid direction: sideways. Allowed values are 'asc' and 'desc'. QueryKitParsingException with the same message
sort Title, Age up ArgumentException: Invalid direction: up. ... QueryKitParsingException with the same message

Main already accepts more than one space before a sort direction (Age desc). This PR does not change that.

Justification

The README says that QueryKitException is the base class of all QueryKit exceptions. On v1.14.2, a bad sort direction escapes a catch (QueryKitException). As a result, an API can return a 500 for a client error. QueryKitParsingException derives from QueryKitException.

Migration

If your code catches ArgumentException from ApplyQueryKitSort or ParseSort, catch QueryKitParsingException or QueryKitException.

Tests

  • New unit test: invalid_sort_direction_throws_query_kit_parsing_exception (2 cases).
  • dotnet test on this branch: 472 unit tests and 297 Postgres integration tests (Testcontainers) pass, 0 failures.

An invalid sort direction (for example `Age sideways`) threw ArgumentException. It now throws QueryKitParsingException with the same message. QueryKitParsingException derives from QueryKitException.

BREAKING CHANGE: an invalid sort direction throws QueryKitParsingException, not ArgumentException. Catch QueryKitParsingException or QueryKitException instead.
@pdevito3
pdevito3 force-pushed the fm/qk-breaking-sort-direction branch from 7d5925f to 2c98981 Compare October 2, 2026 19:57
@pdevito3
pdevito3 changed the base branch from main to v2 October 2, 2026 19:57
@pdevito3
pdevito3 merged commit ee8fdf1 into v2 Oct 2, 2026
2 checks passed
@pdevito3
pdevito3 deleted the fm/qk-breaking-sort-direction branch October 2, 2026 19:59
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