This is an automated email from the ASF dual-hosted git repository.
mattcasters pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 6a565fb044 issue #7507 : restore empty-parameter defaults after
single-JVM runner fix (#7521)
6a565fb044 is described below
commit 6a565fb044601feeafe34786611a48ce2b8d66d5
Author: Matt Casters <[email protected]>
AuthorDate: Tue Jul 14 12:16:54 2026 +0200
issue #7507 : restore empty-parameter defaults after single-JVM runner fix
(#7521)
#7517 preferred any existing same-named variable over empty parameter
defaults and also copied parent variables into nested workflow parameters
when pass_all_parameters=Y. That broke backbone IT main-0004/main-0006
(and hop-run of those workflows alone), while empty defaults are intentional
for unset parameters.
Refine activateParameters to prefer existing variables only when the
parameter default is non-empty (HOSTNAME=localhost clobber case). Revert
ActionWorkflow parent-variable fallback; formal parent parameters still
pass through. Add unit coverage. Ignore SSH samples that need a lab host.
Verified: hop-run alone for main-0004 and main-0006 exits 0. Confirm on
Jenkins.
---
.../apache/hop/core/parameters/NamedParameters.java | 12 +++++++-----
.../hop/core/parameters/NamedParamsDefaultTest.java | 20 ++++++++++++++++----
.../samples/read-samples-build-hop-run.hpl | 8 ++++++++
.../workflow/actions/workflow/ActionWorkflow.java | 11 +++--------
4 files changed, 34 insertions(+), 17 deletions(-)
diff --git
a/core/src/main/java/org/apache/hop/core/parameters/NamedParameters.java
b/core/src/main/java/org/apache/hop/core/parameters/NamedParameters.java
index 24c341dcc6..7c3de311eb 100644
--- a/core/src/main/java/org/apache/hop/core/parameters/NamedParameters.java
+++ b/core/src/main/java/org/apache/hop/core/parameters/NamedParameters.java
@@ -139,14 +139,16 @@ public class NamedParameters implements INamedParameters {
if (StringUtils.isNotEmpty(param.key)) {
String value = param.getValue();
if (StringUtils.isEmpty(value)) {
- // Prefer an already-set variable (environment / parent) over the
parameter default.
- // Nested workflows and pipelines used to clobber env values such as
HOSTNAME or
- // BOOTSTRAP_SERVERS when activateParameters applied empty defaults.
+ String defaultValue = Const.NVL(param.getDefaultValue(), "");
+ // Prefer an already-set variable only when the parameter has a
non-empty default.
+ // That is the HOSTNAME=localhost case: nested files must not
clobber env/project values.
+ // When the default is empty, applying "" is intentional (unset
parameter) and must not
+ // silently adopt a same-named parent CURRENT_WORKFLOW variable —
see IT main-0004/0006.
String existing = variables != null ?
variables.getVariable(param.getKey()) : null;
- if (StringUtils.isNotEmpty(existing)) {
+ if (StringUtils.isNotEmpty(existing) &&
StringUtils.isNotEmpty(defaultValue)) {
value = existing;
} else {
- value = Const.NVL(param.getDefaultValue(), "");
+ value = defaultValue;
}
}
variables.setVariable(param.getKey(), value);
diff --git
a/core/src/test/java/org/apache/hop/core/parameters/NamedParamsDefaultTest.java
b/core/src/test/java/org/apache/hop/core/parameters/NamedParamsDefaultTest.java
index 252630fb1f..409cdd9156 100644
---
a/core/src/test/java/org/apache/hop/core/parameters/NamedParamsDefaultTest.java
+++
b/core/src/test/java/org/apache/hop/core/parameters/NamedParamsDefaultTest.java
@@ -79,22 +79,34 @@ class NamedParamsDefaultTest {
}
@Test
- void testActivateParametersPrefersExistingVariableOverDefault() throws
Exception {
+ void testActivateParametersPrefersExistingVariableOverNonEmptyDefault()
throws Exception {
+ // Nested pipelines often declare HOSTNAME default "localhost"; that must
not clobber env.
Variables variables = new Variables();
variables.setVariable("HOSTNAME", "http");
- variables.setVariable("BOOTSTRAP_SERVERS", "kafka:9092");
namedParams.addParameterDefinition("HOSTNAME", "localhost", "HTTP host");
- namedParams.addParameterDefinition("BOOTSTRAP_SERVERS", "", "Kafka
bootstrap");
namedParams.addParameterDefinition("ONLY_DEFAULT", "from-default", "No
prior variable");
namedParams.activateParameters(variables);
assertEquals("http", variables.getVariable("HOSTNAME"));
- assertEquals("kafka:9092", variables.getVariable("BOOTSTRAP_SERVERS"));
assertEquals("from-default", variables.getVariable("ONLY_DEFAULT"));
}
+ @Test
+ void testActivateParametersEmptyDefaultDoesNotAdoptExistingVariable() throws
Exception {
+ // Empty parameter default means unset: do not silently keep a same-named
parent variable
+ // (integration tests main-0004 / main-0006).
+ Variables variables = new Variables();
+ variables.setVariable("TEST_PARAM", "from-parent-variable");
+
+ namedParams.addParameterDefinition("TEST_PARAM", "", "Empty default");
+
+ namedParams.activateParameters(variables);
+
+ assertEquals("", variables.getVariable("TEST_PARAM"));
+ }
+
@Test
void testActivateParametersExplicitValueWinsOverExistingVariable() throws
Exception {
Variables variables = new Variables();
diff --git a/integration-tests/samples/read-samples-build-hop-run.hpl
b/integration-tests/samples/read-samples-build-hop-run.hpl
index 4397cc9e31..e6bdc4e9bf 100644
--- a/integration-tests/samples/read-samples-build-hop-run.hpl
+++ b/integration-tests/samples/read-samples-build-hop-run.hpl
@@ -559,6 +559,14 @@ var hop_run_cmd = './hop-run.sh -j samples -r ' +
run_config + ' -f ' + filename
<item>rest-client-slack-conversations-loop.hpl</item>
<item>requires SLACK_BOT_TOKEN with channels:read or
conversations:read</item>
</line>
+ <line>
+ <item>ssh-password.hpl</item>
+ <item>requires reachable SSH host (sample points at a private lab
IP)</item>
+ </line>
+ <line>
+ <item>ssh-pri-key.hpl</item>
+ <item>requires SSH private key and reachable SSH host</item>
+ </line>
</data>
<distribute>Y</distribute>
<copies>1</copies>
diff --git
a/plugins/actions/workflow/src/main/java/org/apache/hop/workflow/actions/workflow/ActionWorkflow.java
b/plugins/actions/workflow/src/main/java/org/apache/hop/workflow/actions/workflow/ActionWorkflow.java
index f26323b2b3..e63e75b0d5 100644
---
a/plugins/actions/workflow/src/main/java/org/apache/hop/workflow/actions/workflow/ActionWorkflow.java
+++
b/plugins/actions/workflow/src/main/java/org/apache/hop/workflow/actions/workflow/ActionWorkflow.java
@@ -476,17 +476,12 @@ public class ActionWorkflow extends ActionBase implements
Cloneable, IAction {
// opted to do.
//
if (parameterDefinition.isPassingAllParameters()) {
+ // Only formal parent parameter values are passed here.
Env/project protection for
+ // parameters with non-empty defaults is handled in
NamedParameters.activateParameters
+ // (prefer existing variable over a non-empty default such as
HOSTNAME=localhost).
String parentValue =
parentWorkflow.getParameterValue(parameterName);
if (!Utils.isEmpty(parentValue)) {
workflow.setParameterValue(parameterName, parentValue);
- } else {
- // Match hop-run: if the parent has a variable of the same
name (env, -p as
- // variable, project config), use it so nested main-*.hwf
parameters do not
- // fall back to their local-dev defaults (e.g.
HOSTNAME=localhost).
- String parentVariable =
parentWorkflow.getVariable(parameterName);
- if (!Utils.isEmpty(parentVariable)) {
- workflow.setParameterValue(parameterName, parentVariable);
- }
}
}
}