Skip to content

JMESPath: valid query hits JSONCONS_ASSERT on stack size #605

@Lazrius

Description

@Lazrius

I have a what I believe is a valid query, as it works on all the online playgrounds I have tried, and also works with the Python implementation of JMESPath. The query is as follows:

to_array("gw:GWallInfo"."gw:DocumentStatistics"."gw:ContentGroups"."gw:ContentGroup" || "gw:DocumentStatistics"."gw:ContentGroups"."gw:ContentGroup")[]."gw:IssueItems"."gw:IssueItem" | []

I would expect this query to work fine but it instead results in an assertions being triggered and preventing normal usage.

Minimal Code Example:

#include "jsoncons/basic_json.hpp"
#include "jsoncons_ext/jmespath/jmespath.hpp"

int main(int argc, char* argv[])
{
    auto json = jsoncons::json::parse("{}");
    auto result = jsoncons::jmespath::search(json,
                                             "to_array(\"gw:GWallInfo\".\"gw:DocumentStatistics\".\"gw:ContentGroups\".\"gw:ContentGroup\" || "
                                             "\"gw:DocumentStatistics\".\"gw:ContentGroups\".\"gw:ContentGroup\")[].\"gw:IssueItems\".\"gw:IssueItem\" | []");
    return 0;
}

The exception is thrown on line 2642 of jmespath.hpp, which for me reads: JSONCONS_ASSERT(stack.size() >= 2); - it is inside the token_kind::binary_operator section.

What compiler, architecture, and operating system?

  • Compiler: MSVC Visual Studio 2022
  • Architecture (e.g. x86, x64) x64
  • Operating system: Windows 11

What jsoncons library version?

  • Latest release 1.3.0
  • Other release ______
  • master

If relevant, using the VCPKG version.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions