siddhi-io / siddhi

Stream Processing and Complex Event Processing Engine
http://siddhi.io
Apache License 2.0
1.52k stars 529 forks source link

Invalid validation error when using ENV variables in queries with docker-tooling #1756

Closed vferrandiz closed 2 years ago

vferrandiz commented 2 years ago

Description:

When we try to use environment variables inside queries, a invalid validation error is apperaing in docker-tooling visual editor.

App is running well but we can't generate the design view due to this validation error.

image

Error trace:

[2021-11-10_14-22-34_805] ERROR {io.siddhi.distribution.editor.core.internal.EditorMicroservice} - Unable to generate design view 
io.siddhi.core.exception.SiddhiAppCreationException: Error between @ Line: 28. Position: 0 and @ Line: 28. Position: 33. Syntax error in SiddhiQL, no viable alternative at input 'InputStream[roadFriction <= $'.
    at io.siddhi.distribution.editor.core.util.designview.designgenerator.DesignGenerator.getEventFlow(DesignGenerator.java:58)
    at io.siddhi.distribution.editor.core.internal.EditorMicroservice.getDesignView(EditorMicroservice.java:1089)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.wso2.msf4j.internal.router.HttpMethodInfo.invokeResource(HttpMethodInfo.java:187)
    at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMethodInfo.java:143)
    at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.dispatchMethod(MSF4JHttpConnectorListener.java:218)
    at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.lambda$onMessage$58(MSF4JHttpConnectorListener.java:129)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Affected Siddhi Version:

5.1.2

Steps to reproduce:

Run docker editor 5.1.2.

Create a App that uses a query with ENVIRONMENT variables like:

from InputStream[roadFriction <= ${SLIPPERY_THRESHOLD}]
select id, lat, long, elev, speed, heading, roadFriction
insert into SlipperyRoadStream;

Related Issues: N/A

senthuran16 commented 2 years ago

Hi @vferrandiz , We don't use ${TEMPLATED_VAR}s when writing the Siddhi app in the design view, since ${} would result in a compilation error. Use a hardcoded value when writing the Siddhi app, and to test that. For eg:

@App:name("EnvVarTest")

@App:description("Description of the plan")

define stream InputStream(id string, lat string, lng string, elev string, speed string, heading string, roadFriction double);

from InputStream[roadFriction <= 100]
select id, lat, lng, elev, speed, heading, roadFriction
insert into SlipperyRoadStream;

Then when exporting the Siddhi app to Docker, Step 2 of the Export Siddhi Apps for Docker image wizard provides the option to template a variable. There, you can replace 100 with ${SLIPPERY_THRESHOLD}.