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

Template validation #335

Open
daviatorstorm opened this issue Nov 8, 2023 · 3 comments
Open

Template validation #335

daviatorstorm opened this issue Nov 8, 2023 · 3 comments
Labels

Comments

@daviatorstorm
Copy link

Is it possible to make template validation before creating actual report?

@jjhbw
Copy link
Collaborator

jjhbw commented Nov 11, 2023

The commands in the template are arbitrary JavaScript, so you cannot really validate them without executing the entire template. At least i havent found a convenient way to do so.

To validate user-created templates in my desktop app I just execute them and present any errors that occur to the user. Note that you should be aware of the security concerns related to untrusted/user-generated templates, but that's a different topic.

@jjhbw jjhbw added the question label Nov 11, 2023
@daviatorstorm
Copy link
Author

daviatorstorm commented Nov 11, 2023

Maybe there is a way check template syntax?
I mean to check if commands

+++ QUERI { data { title, description }} +++
    ^^^^^
Error: Syntax error near 1:1. Unknown identifier "QUERI"

are written in the right way but skip values accessing

@jjhbw
Copy link
Collaborator

jjhbw commented Nov 11, 2023

You can use listCommands to get a list of all the commands, but you'll have to parse and validate them using your own custom validation routine.

But still, the only 100% sure way to validate template correctness is by running the code in the template commands, that's the downside of allowing JavaScript in the templates.

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

No branches or pull requests

2 participants