Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Task arguments not parsing correctly #4782

Closed
dgeswein-dlx opened this issue Dec 6, 2021 · 4 comments · Fixed by #4827
Closed

Task arguments not parsing correctly #4782

dgeswein-dlx opened this issue Dec 6, 2021 · 4 comments · Fixed by #4827
Assignees
Labels
type/bug Is a bug report
Milestone

Comments

@dgeswein-dlx
Copy link

I am having difficulty passing a JSON string as an argument to a dataflow task. The quotes and spaces within the JSON are problematic for the parser. I have narrowed the issue to the following method within the dataflow server: org.springframework.cloud.dataflow.rest.util.DeploymentPropertiesUtils.parseArgumentList(String s, String delimiter)

It appears that I can surround my string with quotes to ensure it stays intact, however there is not a clear way to escape the quotes within (don't see anything in the parser that allows for this).

Interestingly, it will parse JSON with spaces and quotes, but only if it is in an odd position within the argument list.

This argument list parses correctly:
arg2="Argument 2" arg3=val3

This argument list does not (the second argument does not remain intact):
arg1=val1 arg2="Argument 2" arg3=val3

This argument list parses correctly:
arg0=val0 arg1=val1 arg2="Argument 2" arg3=val3

I am seeing multiple issues here:

  1. double quoting of arguments with spaces does not preserve the argument value unless it is in an odd position
  2. There does not appear to be a way to escape double quotes within the double quoted text (necessary for JSON)
@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Dec 6, 2021
@aritzbastida
Copy link

aritzbastida commented Feb 7, 2022

I'm having the same issue. As I can see in the logs, the double quotes are escaped by Local Task Launcher (did not try with other deployers yet):

Task launch (REST API):

POST /tasks/executions HTTP/1.1
Content-Type: application/x-www-form-urlencoded
 
name=jt-nuc-jee-OSDoubleSpeedShuttle&arguments=arg%3Dvalue%20base.dir.name%3D%22D%3A%2FTEMP%2FDIR%20WITH%20SPACES%22%20arg2%3Dvalue

Command launched:
2022-02-07 12:13:58.330 INFO 18336 --- [nio-9393-exec-4] o.s.c.d.spi.local.LocalTaskLauncher : Command to be executed: java.exe -jar sample-task.jar arg=value base.dir.name=\"D:/TEMP/DIR WITH SPACES\" arg2=value --spring.cloud.task.executionid=4

Note that double quotes are escaped. As a result, job parameters are misinterpreted by Spring Batch. I found no proper way to pass arguments with spaces (such as a file path) to the job.

@dgeswein-dlx
Copy link
Author

When I opened this issue, I was using the Kubernetes Deployer. The above report from @aritzbastida looks like slightly different behavior than I was experiencing and may even be a different issue related to arg parsing. In any case, parsing of arguments could be improved in DeploymentPropertiesUtils and perhaps other layers as well.

@cppwfs cppwfs added type/bug Is a bug report and removed status/need-triage Team needs to triage and take a first look labels Feb 8, 2022
cppwfs added a commit to cppwfs/spring-cloud-dataflow that referenced this issue Feb 11, 2022
@cppwfs cppwfs self-assigned this Feb 11, 2022
@jvalkeal jvalkeal added this to the 2.10.0-M1 milestone Feb 14, 2022
jvalkeal pushed a commit that referenced this issue Feb 14, 2022
@bjafet123
Copy link

bjafet123 commented Nov 14, 2022

Hi all

I have this issue and I think is related but don't know how to solve it. I'm using the spring-cloud-dataflow-server-2.9.4. I'm trying to obtain a JSON, the issue is when the stream is redeployed.

When I configure my stream to be depoyed, in which I'm using a processor (transform, script or http-request), in the "expression" atribute I need to set an expression that contains quotes and double quotes (escaped). The expression works properly the first time I set and allows to deploy the stream, but if I undeploy the stream and try again to deploy it, the spring cloud data flow throws state machine exception because the backslashes used to escape the double quotes are removed.

I already follow the considerations in the Spaces and Quotes documentation, but I think that it only applies to the streams definition and not to the deployment time.

The URL of the spaces and quotes documentarion is: https://docs.spring.io/spring-cloud-dataflow/docs/current-SNAPSHOT/reference/htmlsingle/#shell-white-space

And the sample of the type of expression required:

expression="new String('{\"size\": 1,\"sort\": {\"timestamp\": \"desc\"},\"query\": {\"prefix\": {\"integrationname\": \"63320e0d3134667225f\"}}}')"

The stream could be as simple as:

http | transform | log

The firs time the expression in the transform processor is set looks like as follows:

expression="new String('{\"size\": 1,\"sort\": {\"timestamp\": \"desc\"},\"query\": {\"prefix\": {\"integrationname\": \"63320e0d313862934667225f\"}}}')"

Deploying correctly the stream.

Once the stream is undeployed and try to deploy it again, the espression looks like:

expression="new String('{"size": 1,"sort\": {"timestamp": "desc"},"query": {"prefix": {"integrationname": "63320e0d313862934667225f"}}}')"

Where the backslashes were removed, causing the state machine exception because of the unescaped double quotes. This behavior prevents to automate the deployment of the streams.

Thanks in advance

@cppwfs
Copy link
Contributor

cppwfs commented Nov 14, 2022

@bjafet123 Please open a new issue for this report. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/bug Is a bug report
Development

Successfully merging a pull request may close this issue.

5 participants