-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(api): parses some of the data as [OBJECT OBJECT] #7280
fix(api): parses some of the data as [OBJECT OBJECT] #7280
Conversation
✅ Deploy Preview for dev-web-novu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for dashboard-v2-novu-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
const INVALID_VARIABLE_PLACEHOLDER = '<INVALID_VARIABLE_PLACEHOLDER>'; | ||
const PREVIEW_ERROR_MESSAGE_PLACEHOLDER = `[[Invalid Variable: ${INVALID_VARIABLE_PLACEHOLDER}]]`; |
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 am open to error message suggestions :)
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.
Now, the liquid parser is aware of the Novu-supported variables, and it passes it to its client.
if (keys.length === 1) { | ||
return; | ||
} |
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.
this solves cases if user provides the following control value:
{{subscriber}} {{subscriber.firstName}}
in such case API would trow 500 TypeError: Cannot create property 'firstName' on string '{{subscriber}}'
* we need to remove the '{{' and '}}' from the invalid variable name | ||
* so that framework can parse it without errors | ||
*/ | ||
const invalidVariableExpression = invalidVariable.name.replace('{{', '').replace('}}', ''); |
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.
self note: need to replace all (the same) invalid outputs at once here.
const invalidVariableExpression = invalidVariable.name.replace('{{', '').replace('}}', ''); | |
const invalidVariableExpression = invalidVariable.name.replaceAll('{{', '').replace('}}', ''); |
this progress was cherry-picked to #7303 |
What changed? Why was the change needed?
this PR solves the issue that was raised, but there are still issues with the preview we will need to solve. i was not able to solve anything that was happening in PrepareAndValidateContentUsecase, because changing one issue caused another.
Note: This PR addresses all potential Liquid JS runtime errors during the preview process, based on the current Novu implementation, which supports basic Liquid JS output with filters.
Here is a summary i was able to do while working on this ticket:
{{subscriber}}
{{subscriber}} {{subscriber.firstName}}
TypeError: Cannot create property 'firstName' on string '{{subscriber}}'
.{{subscriber asd}}
{{payload..name | upcase}}
BridgeRequestError: Workflow with id: asd-opyf has invalid controls syntax in step with id: in-app-step. Please correct step control syntax.
(Liquid.js fails to parse invalid template output.){{payload | upcase}}
[OBJECT OBJECT]
.payload
variable. In the pipeline,payload: {}
is passed, and Liquid.js outputs{}.toString()
.- SOLVED: Now replaced with text ([[Invalid Variable: ...]]).
{{payload.name ca}}
{{payload.name ca | upcase}}
payload.name
variable. Since the variable is not provided, it renders nothing.{{payload}} or {{payload adasds}}
Example of before
After
Expand for optional sections
Related enterprise PR
Special notes for your reviewer