This is an automated email from the ASF dual-hosted git repository.

bamaer 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 a577fe7c64 Apply pipeline parameters when indexing lint references 
(#9425)
a577fe7c64 is described below

commit a577fe7c64093f0d31006c8ecd8ea419c2b09deb
Author: Gabriel Dutra <[email protected]>
AuthorDate: Thu Nov 12 00:22:36 2026 -0700

    Apply pipeline parameters when indexing lint references (#9425)
---
 .../java/org/apache/hop/lint/LintProjectIndex.java | 18 ++++++++-
 .../org/apache/hop/lint/LintProjectIndexTest.java  | 44 ++++++++++++++++++++++
 2 files changed, 60 insertions(+), 2 deletions(-)

diff --git 
a/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintProjectIndex.java 
b/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintProjectIndex.java
index 3a7e2af5a2..331c67b921 100644
--- a/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintProjectIndex.java
+++ b/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintProjectIndex.java
@@ -23,10 +23,12 @@ import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
+import org.apache.hop.core.Const;
 import org.apache.hop.core.logging.ILogChannel;
 import org.apache.hop.core.logging.LogChannel;
 import org.apache.hop.core.util.Utils;
 import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.core.variables.Variables;
 import org.apache.hop.metadata.api.IHopMetadataProvider;
 import org.apache.hop.pipeline.PipelineMeta;
 import org.apache.hop.pipeline.transform.TransformMeta;
@@ -118,15 +120,27 @@ public final class LintProjectIndex {
   }
 
   private void addPipelineReferences(PipelineMeta meta, String from, 
IVariables variables) {
+    Variables pipelineVariables = new Variables();
+    pipelineVariables.copyFrom(variables);
+    for (String parameter : meta.listParameters()) {
+      try {
+        pipelineVariables.setVariable(
+            parameter, Const.NVL(meta.getParameterDefault(parameter), ""));
+      } catch (Exception e) {
+        log.logDetailed(
+            "Could not apply parameter '" + parameter + "' from " + from + ": 
" + e.getMessage());
+      }
+    }
+
     for (TransformMeta transformMeta : meta.getTransforms()) {
       if (transformMeta.getTransform() == null) {
         continue;
       }
       try {
         record(
-            transformMeta.getTransform().getResourceDependencies(variables, 
transformMeta),
+            
transformMeta.getTransform().getResourceDependencies(pipelineVariables, 
transformMeta),
             from,
-            variables);
+            pipelineVariables);
       } catch (Exception e) {
         log.logDetailed(
             "Could not read references from transform '"
diff --git 
a/plugins/misc/lint/src/test/java/org/apache/hop/lint/LintProjectIndexTest.java 
b/plugins/misc/lint/src/test/java/org/apache/hop/lint/LintProjectIndexTest.java
index 4be1b56db4..2dec8a69be 100644
--- 
a/plugins/misc/lint/src/test/java/org/apache/hop/lint/LintProjectIndexTest.java
+++ 
b/plugins/misc/lint/src/test/java/org/apache/hop/lint/LintProjectIndexTest.java
@@ -19,12 +19,24 @@ package org.apache.hop.lint;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockConstruction;
+import static org.mockito.Mockito.when;
 
 import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.regex.Pattern;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.core.variables.Variables;
 import org.apache.hop.pipeline.PipelineMeta;
+import org.apache.hop.pipeline.transform.ITransformMeta;
+import org.apache.hop.pipeline.transform.TransformMeta;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
+import org.mockito.MockedConstruction;
 
 class LintProjectIndexTest {
 
@@ -91,6 +103,38 @@ class LintProjectIndexTest {
     assertFalse(index.isFileReferenced("/project/pipelines/a.hpl"));
   }
 
+  @Test
+  void pipelineParameterDefaultsAreUsedWhenReadingReferences() throws 
Exception {
+    Variables variables = new Variables();
+    TransformMeta transformMeta = mock(TransformMeta.class);
+    ITransformMeta transform = mock(ITransformMeta.class);
+    AtomicReference<String> resolvedMask = new AtomicReference<>();
+    when(transformMeta.getTransform()).thenReturn(transform);
+    when(transform.getResourceDependencies(any(IVariables.class), 
any(TransformMeta.class)))
+        .thenAnswer(
+            invocation -> {
+              IVariables pipelineVariables = invocation.getArgument(0);
+              String mask = 
pipelineVariables.resolve("person-info-${PRM_TYPE}.csv");
+              resolvedMask.set(mask);
+              Pattern.compile(mask);
+              return List.of();
+            });
+
+    try (MockedConstruction<PipelineMeta> ignored =
+        mockConstruction(
+            PipelineMeta.class,
+            (meta, context) -> {
+              when(meta.getTransforms()).thenReturn(List.of(transformMeta));
+              when(meta.listParameters()).thenReturn(new String[] 
{"PRM_TYPE"});
+              when(meta.getParameterDefault("PRM_TYPE")).thenReturn("1");
+            })) {
+      LintProjectIndex.build(List.of("/project/process-files-with-mdi.hpl"), 
null, variables);
+    }
+
+    assertEquals("person-info-1.csv", resolvedMask.get());
+    assertNull(variables.getVariable("PRM_TYPE"), "the lint run variables must 
not be changed");
+  }
+
   @Test
   void nothingIsReferencedInAnEmptyIndex() {
     LintProjectIndex index = LintProjectIndex.empty();

Reply via email to