-
Notifications
You must be signed in to change notification settings - Fork 3
Fix: Added invalid JSON check on payment triggers #1028
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
Conversation
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.
Pull Request Overview
This PR adds JSON validation to payment triggers to prevent network requests when the trigger's JSON data is invalid. The change addresses issue #765 by implementing early JSON validation that logs errors without attempting external HTTP calls.
- Added try-catch wrapper around JSON parsing in
postDataForTriggerfunction - Implemented early return with error logging when JSON validation fails
- Added comprehensive test coverage for the new validation behavior
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| services/triggerService.ts | Added JSON validation with early return and error logging before network requests |
| tests/unittests/triggerService.test.ts | Added unit tests demonstrating JSON validation functionality |
| tests/integration-tests/triggerJsonValidation.test.ts | Added integration tests covering various JSON validation scenarios |
chedieck
left a comment
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.
just a minor thing
chedieck
left a comment
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 added a console error, since this situation should never happen unless we manual edit the db, and fixed linting issues (check if you have ./git/hooks/pre-commit in place, if not copy it there from .githooks/).
chedieck
left a comment
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 fixed some linting issues and some stuff that was erroring due to changes in master.
In any case, I looked further and didn't undestand the reason for the tests included in the tests/integration-tests/triggerJsonValidation.test.ts to be in a separate file from the other trigger tests — I don't understand why they are included in integration-tests/ since, AFAIK, they are not testing any integration.
Klakurka
left a comment
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.
Right, thanks.
I consolidated those tests, cleaned it up a bit.
Have a look at the lint-staged changes I had to make to be able to build - this is an issue for me that I had to fix in another WIP branch.
This reverts commit 342f5c5.
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.
Just a typo mistake.
Have a look at the
lint-stagedchanges I had to make to be able to build - this is an issue for me that I had to fix in another WIP branch.
I don't see it, did you commit it in this branch?
Related to #765
Description
Added check to make sure we aren't firing off payment triggers with invalid JSON.
Test plan