Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match reporting error #247

Closed
charles-paperman opened this issue Sep 5, 2023 · 3 comments · Fixed by #268
Closed

Match reporting error #247

charles-paperman opened this issue Sep 5, 2023 · 3 comments · Fixed by #268
Assignees
Labels
area: result Improvements in query result reporting good first issue Good for newcomers help wanted External contributions welcome type: bug Something isn't working
Milestone

Comments

@charles-paperman
Copy link
Collaborator

Package

Library

Describe the bug

When using RsonpathEngin.matches the end offset is pointing toward the next structural character.

Minimal Reproducible Example

With the JSON

{"a": {"b": "c"}, "c": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}'
  • The query .a.b get the matches 12-16 which gives the slice: '"c"}'
  • The query .c[5] get the matches 39-41 which gives the slice: 5,

Expected behavior

With the JSON

{"a": {"b": "c"}, "c": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}'
  • The query .a.b get the matches 12-15 which gives the slice: "c"
  • The query .c[5] get the matches 39-41 which gives the slice: 5

Workarounds (optional)

No response

Proposed solution (optional)

No response

Version of the release

v0.7.0

Rust version

nightly

Target triple

x86_64

Features enabled

default

Codegen options

No response

Additional context (optional)

No response

@charles-paperman charles-paperman added the type: bug Something isn't working label Sep 5, 2023
@github-actions github-actions bot added the acceptance: triage Waiting for owner's input label Sep 5, 2023
@github-actions
Copy link

github-actions bot commented Sep 5, 2023

Tagging @V0ldek for notifications

@V0ldek
Copy link
Member

V0ldek commented Sep 5, 2023

Yup, full repro.

The bug is in the nodes recorders, both the simple one (line 308 and the stack (line 475). We finalize_node to trim the whitespace but don't actually propagate that to the end index. The fix is easy, the end index should be simply taken as start_idx + buf.len() - 1.

Will prioritize for next version.

@V0ldek V0ldek added this to the v1.0.0 milestone Sep 5, 2023
@V0ldek V0ldek self-assigned this Sep 5, 2023
@github-actions github-actions bot added acceptance: go ahead Reviewed, implementation can start and removed acceptance: triage Waiting for owner's input labels Sep 5, 2023
@V0ldek V0ldek added help wanted External contributions welcome good first issue Good for newcomers mod: engine area: result Improvements in query result reporting labels Sep 5, 2023
V0ldek added a commit that referenced this issue Sep 17, 2023
-Fixed a bug where `MatchSpan` values given by the engine were
    almost always invalid.

Ref: #247
V0ldek added a commit that referenced this issue Sep 17, 2023
-Fixed a bug where `MatchSpan` values given by the engine were
    almost always invalid.

Ref: #247
V0ldek added a commit that referenced this issue Sep 18, 2023
-Fixed a bug where `MatchSpan` values given by the engine were
    almost always invalid.

Ref: #247
@github-actions github-actions bot removed the acceptance: go ahead Reviewed, implementation can start label Sep 18, 2023
@V0ldek
Copy link
Member

V0ldek commented Sep 20, 2023

Fixed in v0.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: result Improvements in query result reporting good first issue Good for newcomers help wanted External contributions welcome type: bug Something isn't working
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

2 participants