bamaer commented on code in PR #9460:
URL: https://github.com/apache/hop/pull/9460#discussion_r4555738653
##########
plugins/transforms/setvariable/src/main/java/org/apache/hop/pipeline/transforms/setvariable/SetVariable.java:
##########
@@ -147,18 +147,19 @@ private void setValue(Object[] rowData, int i, boolean
usedefault) throws HopExc
// Make a link between the pipeline and the parent pipeline (in a
sub-pipeline)
//
- while (pipeline.getParentPipeline() != null) {
- pipeline = pipeline.getParentPipeline();
- pipeline.setVariable(varname, value);
+ IVariables currentVariables = getPipeline();
+ while (currentVariables != null) {
+ currentVariables.setVariable(varname, value);
+ currentVariables = currentVariables.getParentVariables();
Review Comment:
**Blocker:** this loop sets the variable on every `IVariables` up the chain,
whatever variable type is selected, so the `switch` below no longer limits the
scope. A pipeline in a child workflow with "Valid in the parent workflow" now
also overwrites the variable in the root workflow. Root workflow → child
workflow → pipeline that sets `VA`:
- main: child `VA=[set]`, root `VA=[${VA}]` (unset)
- this PR: child `VA=[set]`, root `VA=[set]`
That silently changes the result of existing workflows. When a workflow is
run from Hop GUI, the chain also continues past the root workflow into the
editor tab's own variables, so a value can carry over into the next run in that
tab (from reading the code, not run). Suggested fix: keep main's loop over
`getParentPipeline()` and `getParentEngine()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]