-
Notifications
You must be signed in to change notification settings - Fork 22
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
Added JSONPath syntactic validation #561
Added JSONPath syntactic validation #561
Conversation
✅ Deploy Preview for taco-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for taco-nft-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thank you for this. I thought the jsonpath
package was deprecated now though? and has been replaced by jsonpath-plus
packages/taco/package.json
Outdated
@@ -43,11 +43,13 @@ | |||
"@nucypher/nucypher-core": "*", | |||
"@nucypher/shared": "workspace:*", | |||
"ethers": "^5.7.2", | |||
"jsonpath": "^1.1.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @theref noted, this package seems to be no longer maintained. jsonpath-plus
is in maintenance mode:
Please note: This project is not currently being actively maintained. We may accept well-documented PRs or some simple updates, but are not looking to make fixes or add new features ourselves.
We may want to switch to jsonpath-plus
or https://www.npmjs.com/package/nimma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the same message on the JSONPath-plus GitHub (https://github.com/JSONPath-Plus/JSONPath)
![Screenshot 2024-07-31 at 14 42 17](https://private-user-images.githubusercontent.com/679404/353740911-3716c790-6a68-4f93-a888-e6c367cb2c55.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MTM2NjIsIm5iZiI6MTczOTQxMzM2MiwicGF0aCI6Ii82Nzk0MDQvMzUzNzQwOTExLTM3MTZjNzkwLTZhNjgtNGY5My1hODg4LWU2YzM2N2NiMmM1NS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxM1QwMjIyNDJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03OThhOTUyZjBkZGI3OWU5ZmIxMzFjYzM5ZDg2Zjg4YWQ4MTE5YmFmNjE1NmQ4ZDM0OTdjZmYzMmZlMTY2NmViJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.cWm0UUMmIUq73RxUiP29C8dsbUMFZqSg949yhdxRn3g)
This messaging also appears to be reiterated in this comment on May 15, 2024 JSONPath-Plus/JSONPath#173 (comment)
As mentioned on the main page of the README, I am not actively maintaining this project, though I am accepting PRs. Feel free to submit a well-documented PR if you find an issue and your question is not answered by the README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, since there appears to be no actively maintained jsonpath package, if the original jsonpath package is functioning as expected (demonstrated in this PR) I'm in favor of merging it as-is if we can get CI to pass.
After all, the only functionality we actually need is the syntactic check and not the evaluation. If jsonpath supports that but jsonpath-plus does not I don't think we have another way to implement this validator without building our own regular expressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to various issues with jsonpath and jsonpath-plus not functioning as expected, I decided to implement our own JSONPath validator.
eb78af3
to
4383192
Compare
re: CI failures From @piotr-roslaniec : """
""" |
@andresceballosm can you try using https://www.npmjs.com/package/@astronautlabs/jsonpath (https://github.com/astronautlabs/jsonpath) instead of |
Hey @derekpierre works great! thanks |
const invalidPath = '$.store.book[?(@.price < ]'; | ||
const result = jsonPathSchema.safeParse(invalidPath); | ||
expect(result.success).toBe(false); | ||
if (!result.success) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these if
statements necessary? If not, let's remove them. We know result.success
is false from the expect in the line above. Same comment for other tests below.
if (!result.success) { | ||
expect(result.error.errors[0].message).toBe( | ||
'Invalid JSONPath expression', | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not being more clear. I meant to keep the expect
test but remove the if
i.e. keep only
expect(result.error.errors[0].message).toBe(
'Invalid JSONPath expression',
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎸 - nice work!
Type of PR:
Required reviews:
What this does:
Related to https://github.com/nucypher/taco-web/pull/550/files#r1696888086
Issues fixed/closed:
Why it's needed:
Notes for reviewers:
This depends on the PR #550
With the integrated PR #550 my approach is to use it in the following way