Skip to content

Tidy up: stop literal-only filters from matching all elements (JsonPath.java) #183

Open

Description

@simbo1905

Sub-issue 4 of 26 from the 2026-11-21 bot-review-comment audit. Parent issue: #179 (Bot review comment tidy up).
Audited origin/main HEAD: 2e5cf37. Audit date: 2026-11-21.

== Finding 4 (verbatim from the audit findings file) ==

  1. PR JsonPath AST and matching #124 — matchesFilter returns true for ANY LiteralValue (e.g. [?(false)] matches everything).
    Author: gemini-code-assist[bot], 2026-02-01. Comment: JsonPath AST and matching #124 (comment)
    Source: json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPath.java:307. Current: json-java21-jsonpath/src/main/java/json/java21/jsonpath/JsonPath.java:342 (case JsonPathAst.LiteralValue ignored -> true;).
    Flagged: "a filter expression like [?(false)] or [?(0)] would incorrectly match all elements". Suggested: yield the boolean only for Boolean literals, false otherwise.
    Still applies: current parser (JsonPathParser.parseFilterAtom, lines 289-320) now CAN produce a standalone literal as the whole filter, so the case is reachable and still returns true for false/0/'' — e.g. [?(false)] matches every element.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions