Skip to content

fix(parser)!: throw ParsingException for a value that does not convert - #162

Open
pdevito3 wants to merge 1 commit into
mainfrom
fm/qk-breaking-2x
Open

pdevito3 wants to merge 1 commit into
mainfrom
fm/qk-breaking-2x

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

A filter value that does not convert to the property type throws ParsingException. On v1.14.2 and main, the same filter throws FormatException or OverflowException. The original exception is now the inner exception of the ParsingException.

Old behavior (v1.14.2 and main)

Input Result
Age == "abc", Age == abc, Rating > abc FormatException
Age == 99999999999 OverflowException
Id == "abc", SpecificDateTime == "abc", Favorite == "abc", Age ^^ ["abc"] FormatException

New behavior

Each input in the table throws ParsingException. ParsingException derives from QueryKitException. The inner exception is the FormatException or the OverflowException, with its message.

Justification

The README says that QueryKitException is the base class of all QueryKit exceptions, and that a consumer can catch it. On v1.14.2, a bad value escapes this catch. As a result, an API can return a 500 for a client error. After the change, one catch (QueryKitException) handles every bad filter value.

Migration

  • If your code catches FormatException or OverflowException from ApplyQueryKitFilter or ParseFilter, catch ParsingException or QueryKitException.
  • If your code reads the conversion details, read InnerException.

Interaction with other PRs

#159 (D4, on main) throws ParsingException for a '.' number that the culture can not read. Its test number_that_v1_14_2_also_converted_throws_format_exception pins the v1.14.2 FormatException for other numbers. This PR renames it to number_that_v1_14_2_also_converted_throws_parsing_exception and expects ParsingException with an inner FormatException. The test failure_before_the_query_name_throws_its_own_format_exception (from #160) changes in the same way.

Tests

  • New unit test: invalid_value_throws_parsing_exception (9 cases).
  • New integration test: invalid_value_throws_parsing_exception (4 cases, Postgres).
  • dotnet test on this branch: 479 unit tests and 301 Postgres integration tests (Testcontainers) pass, 0 failures.

A value that does not convert to the property type (for example `Age == "abc"`, `Rating > abc`, or an int overflow) threw FormatException or OverflowException. It now throws ParsingException, with the original exception as the inner exception.

BREAKING CHANGE: a bad filter value throws ParsingException, not FormatException or OverflowException. Catch ParsingException or QueryKitException instead. The inner exception keeps the original details.
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