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

fear(api): wip refactor liquid parser #7280

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

djabarovgeorge
Copy link
Contributor

@djabarovgeorge djabarovgeorge commented Dec 11, 2024

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.

here is a summery i was able to do while working on this ticket:

  1. {{subscriber}}

    • No issue generated. OPEN ISSUE
    • Preview: Displays {{subscriber}}.
      • SOLVED: Now replaced with text ([[Invalid Variable: ...]]).
  2. {{subscriber}} {{subscriber.firstName}}

  3. {{subscriber asd}}

    • Issue generated. GOOD
    • Preview: Empty (removed in the prepare... use case). OPEN ISSUE
  4. {{payload..name | upcase}}

    • Issue generated. GOOD
    • Preview framework: Fails with 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.)
      • SOLVED: Now replaced with text ([[Invalid Variable: ...]]).
  5. {{payload | upcase}}

    • Issue generated. GOOD
    • Preview: Displays [OBJECT OBJECT].
    • Why? This is valid Liquid.js output for the payload variable. In the pipeline, payload: {} is passed, and Liquid.js outputs {}.toString().
      - SOLVED: Now replaced with text ([[Invalid Variable: ...]]).
  6. {{payload.name ca}}

    • Issue generated. GOOD
    • Preview: Empty (removed in the prepare... use case). OPEN ISSUE
  7. {{payload.name ca | upcase}}

    • Issue generated. GOOD
    • Preview: Empty (removed in the prepare... use case).
    • Why? This is valid Liquid.js output for the payload.name variable. Since the variable is not provided, it renders nothing.
      • SOLVED: Now replaced with text ([[Invalid Variable: ...]]).
  8. {{payload}} or {{payload adasds}}

    • Issue generated. GOOD
    • Preview: Empty (removed in the prepare... use case). OPEN ISSUE

Example of before

image

After

image

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

linear bot commented Dec 11, 2024

Copy link

netlify bot commented Dec 11, 2024

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit 2d5d785
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/6759f7b7f2cb6600087befb2
😎 Deploy Preview https://deploy-preview-7280.dashboard.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Dec 11, 2024

Hey there and thank you for opening this pull request! 👋

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Your PR title is: fear(api): wip refactor liquid parser
It should be something like: feat(scope): Add fancy new feature

Details:

Unknown release type "fear" found in pull request title "fear(api): wip refactor liquid parser".

Available types:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit

Copy link

netlify bot commented Dec 11, 2024

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit 2d5d785
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/6759f7b72b2a8d000857bdab
😎 Deploy Preview https://deploy-preview-7280.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +32 to +33
const INVALID_VARIABLE_PLACEHOLDER = '<INVALID_VARIABLE_PLACEHOLDER>';
const PREVIEW_ERROR_MESSAGE_PLACEHOLDER = `[[Invalid Variable: ${INVALID_VARIABLE_PLACEHOLDER}]]`;
Copy link
Contributor Author

@djabarovgeorge djabarovgeorge Dec 11, 2024

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 :)

Copy link
Contributor Author

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.

Comment on lines +66 to +68
if (keys.length === 1) {
return;
}
Copy link
Contributor Author

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}}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant