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

[Bug] [setValue] if "\n" in variable, then setValue function will work bad #15136

Closed
2 of 3 tasks
kevinkelin opened this issue Nov 8, 2023 · 9 comments · Fixed by #15145
Closed
2 of 3 tasks

[Bug] [setValue] if "\n" in variable, then setValue function will work bad #15136

kevinkelin opened this issue Nov 8, 2023 · 9 comments · Fixed by #15145
Assignees
Labels
document improvement make more easy to user or prompt friendly
Milestone

Comments

@kevinkelin
Copy link
Contributor

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

In python task , if a variable has "\n", then use setValue to make a Parameter for next node, the variable will not work well

node_one

s = "hello \n world"
print("${setValue(message=%s)}"%s)

node_two

echo "${message}"

echo "hi"

check runtime log

node_one

[INFO] 2023-11-08 10:51:02.588 +0800 - process start, process id is: 10376
[INFO] 2023-11-08 10:51:03.588 +0800 -  -> 
	 world)}
[INFO] 2023-11-08 10:51:03.590 +0800 - process has exited. execute 

node_two

[INFO] 2023-11-08 10:51:04.374 +0800 - process start, process id is: 30190
[INFO] 2023-11-08 10:51:05.374 +0800 -  -> 
	
	hi
[INFO] 2023-11-08 10:51:05.375 +0800 - process has exited. execute

What you expected to happen

In node_two, when echo "${message}" will show the Parameter set in pre task, in this case, want show “hello \n world"

How to reproduce

create a workflow, the first task use python task, make a variable include "\n", then use setValue to make a Parameter

Anything else

No response

Version

3.2.x

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@kevinkelin kevinkelin added bug Something isn't working Waiting for reply Waiting for reply labels Nov 8, 2023
@Radeity Radeity added help wanted Extra attention is needed and removed Waiting for reply Waiting for reply labels Nov 8, 2023
@Radeity Radeity added this to the 3.2.1 milestone Nov 8, 2023
@Radeity Radeity added the good first issue good first issue label Nov 8, 2023
@Radeity
Copy link
Member

Radeity commented Nov 8, 2023

Hi @kevinkelin , according to the above logs of node_one, seems like it doesn't print ${setValue(key=value}.

@kevinkelin
Copy link
Contributor Author

Hi @kevinkelin , according to the above logs of node_one, seems like it doesn't print ${setValue(key=value}.

if setValue work well, there will not print any thing, but in this case, it print world)}

@Radeity
Copy link
Member

Radeity commented Nov 8, 2023

Hi @kevinkelin , according to the above logs of node_one, seems like it doesn't print ${setValue(key=value}.

if setValue work well, there will not print any thing, but in this case, it print world)}

You should make sure ${setValue(key=value} exists in stdout of node_one.

@kevinkelin
Copy link
Contributor Author

Hi @kevinkelin , according to the above logs of node_one, seems like it doesn't print ${setValue(key=value}.

if setValue work well, there will not print any thing, but in this case, it print world)}

You should make sure ${setValue(key=value} exists in stdout of node_one.

I resolve this issue

node_one

s = "hello \n world"
print("${setValue(message=%s)}"%repr(s))

node_two

echo "${message}"

echo "hi"

In node_onw, python task must use repr(s) for formating string

so consider about how to optimize this Issue.

@Radeity
Copy link
Member

Radeity commented Nov 8, 2023

You're right, actually, the cause of the issue is that we find output parameter in a single line, so in your resolution, use repr to read \n, then in stdout, this line will be ${setValue(message=hello \n world)}.

if (line.startsWith("${setValue(") || line.startsWith("#{setValue(")) {
    varPool.append(findVarPool(line));
    varPool.append("$VarPool$");
}

I think we don't have to fix it, instead, we can declare more clearly in our doc, WDYT?

@kevinkelin
Copy link
Contributor Author

You're right, actually, the cause of the issue is that we find output parameter in a single line, so in your resolution, use repr to read \n, then in stdout, this line will be ${setValue(message=hello \n world)}.

if (line.startsWith("${setValue(") || line.startsWith("#{setValue(")) {
    varPool.append(findVarPool(line));
    varPool.append("$VarPool$");
}

I think we don't have to fix it, instead, we can declare more clearly in our doc, WDYT?

I think is OK, make doc clearly, so that users can avoid this problem.

@Radeity
Copy link
Member

Radeity commented Nov 8, 2023

Would you like to help enhance the doc? @kevinkelin

@kevinkelin
Copy link
Contributor Author

Would you like to help enhance the doc? @kevinkelin

OK, how to enhance the doc?

@Radeity
Copy link
Member

Radeity commented Nov 8, 2023

You can submit PR to this repo, ref #15028

@Radeity Radeity added improvement make more easy to user or prompt friendly document and removed help wanted Extra attention is needed good first issue good first issue bug Something isn't working labels Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
document improvement make more easy to user or prompt friendly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants