Skip to content

Copilot/fix error handling no matches#39

Merged
MichalFrends1 merged 2 commits into
mainfrom
copilot/fix-error-handling-no-matches
Jul 8, 2026
Merged

Copilot/fix error handling no matches#39
MichalFrends1 merged 2 commits into
mainfrom
copilot/fix-error-handling-no-matches

Conversation

@jefim

@jefim jefim commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Dear PR creator, please select one of the PR templates, then remove others and this text.


Default PR template

Please review my changes :)


Task Update PR template

Review Checklist

  • Task version updated (x.x.0)
  • CHANGELOG.md updated
  • Solution builds
  • Warnings resolved (if possible)
  • Typos resolved
  • Tests cover new code
  • Description how to run tests locally added to README.md (if needed)
  • All tests pass locally

Summary by CodeRabbit

  • Bug Fixes
    • Query and QuerySingle now throw an exception when ErrorWhenNotMatched is enabled and no JSONPath results are found.
    • This makes failed matches easier to detect instead of returning an empty or null result.
  • Tests
    • Added coverage for the no-match exception behavior in both query operations.
  • Chores
    • Updated package versions and changelog entries for the new release.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Both Query and QuerySingle methods now throw a JsonException when Options.ErrorWhenNotMatched is enabled and the JSONPath filter matches no results, instead of silently returning empty/null. Changes include new unit tests, changelog entries, and version bumps (1.1.0→1.2.0, 1.2.0→1.3.0) for the respective packages.

Changes

JSON.Query and JSON.QuerySingle exception handling

Layer / File(s) Summary
Query throws on empty match
Frends.JSON.Query/Frends.JSON.Query/Query.cs
Query materializes SelectTokens results into a List and throws JsonException when the list is empty and ErrorWhenNotMatched is true.
Query tests and release notes
Frends.JSON.Query/Frends.JSON.Query.UnitTests/UnitTests.cs, Frends.JSON.Query/CHANGELOG.md, Frends.JSON.Query/Frends.JSON.Query/Frends.JSON.Query.csproj
New test asserts JsonException is thrown; changelog documents the fix; package version bumped to 1.2.0.
QuerySingle throws on null match
Frends.JSON.QuerySingle/Frends.JSON.QuerySingle/QuerySingle.cs
QuerySingle stores SelectToken result in a variable, checks for null, and throws JsonException when ErrorWhenNotMatched is true.
QuerySingle tests and release notes
Frends.JSON.QuerySingle/Frends.JSON.QuerySingle.UnitTests/UnitTests.cs, Frends.JSON.QuerySingle/CHANGELOG.md, Frends.JSON.QuerySingle/Frends.JSON.QuerySingle/Frends.JSON.QuerySingle.csproj
New test asserts JsonException is thrown; changelog documents the fix; package version bumped to 1.3.0.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: ttossavainen

Poem

A rabbit hops through JSON trees so deep,
When no match found, no silence to keep,
A JsonException now hops out with glee,
Two packages bumped, versions set free,
🐇 Fixed and tested, tidy as can be!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and clearly relates to the main change: fixing no-match error handling.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch copilot/fix-error-handling-no-matches

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MichalFrends1 MichalFrends1 merged commit aa04fda into main Jul 8, 2026
6 checks passed
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.

3 participants