You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2026/06/12 09:55:54 UTC

(hop) branch main updated: Metadata Injection Error instead of Warning for deleted target keys, fixes #7279 (#7280)

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

hansva 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 8b20e2125e Metadata Injection Error instead of Warning for deleted target keys, fixes  #7279 (#7280)
8b20e2125e is described below

commit 8b20e2125ec55836a986248f1cc2c0b53ea930af
Author: Hans Van Akelyen <ha...@gmail.com>
AuthorDate: Fri Jun 12 11:55:48 2026 +0200

    Metadata Injection Error instead of Warning for deleted target keys, fixes  #7279 (#7280)
---
 .../pipeline/transforms/metainject/MetaInject.java | 12 ++++---
 .../metainject/messages/messages_en_US.properties  |  1 +
 .../transforms/metainject/MetaInjectTest.java      | 39 ++++++++++++++++++++++
 3 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/plugins/transforms/metainject/src/main/java/org/apache/hop/pipeline/transforms/metainject/MetaInject.java b/plugins/transforms/metainject/src/main/java/org/apache/hop/pipeline/transforms/metainject/MetaInject.java
index 58abda44b1..0e1b5ba5c0 100644
--- a/plugins/transforms/metainject/src/main/java/org/apache/hop/pipeline/transforms/metainject/MetaInject.java
+++ b/plugins/transforms/metainject/src/main/java/org/apache/hop/pipeline/transforms/metainject/MetaInject.java
@@ -369,7 +369,7 @@ public class MetaInject extends BaseTransform<MetaInjectMeta, MetaInjectData> {
     }
   }
 
-  private void collectDataForOneMapping(
+  void collectDataForOneMapping(
       String targetTransformName,
       MetaInjectMapping mapping,
       Map<String, Set<String>> injectionKeyGroupMap,
@@ -407,10 +407,12 @@ public class MetaInject extends BaseTransform<MetaInjectMeta, MetaInjectData> {
           targetMetaClass, mapping.getTargetAttributeKey())) {
         collectInjectionKeyValue(this, mapping, sourceRows, injectionKeyData);
       } else {
-        throw new HopTransformException(
-            "The injection group key for target key '"
-                + mapping.getTargetAttributeKey()
-                + "' was not found.");
+        logBasic(
+            BaseMessages.getString(
+                PKG,
+                "MetaInject.TargetKeyNotFound.Warning",
+                mapping.getTargetAttributeKey(),
+                targetTransformName));
       }
     } else {
       // A simple property from the first row.
diff --git a/plugins/transforms/metainject/src/main/resources/org/apache/hop/pipeline/transforms/metainject/messages/messages_en_US.properties b/plugins/transforms/metainject/src/main/resources/org/apache/hop/pipeline/transforms/metainject/messages/messages_en_US.properties
index ba10deeca9..eab42cafdc 100644
--- a/plugins/transforms/metainject/src/main/resources/org/apache/hop/pipeline/transforms/metainject/messages/messages_en_US.properties
+++ b/plugins/transforms/metainject/src/main/resources/org/apache/hop/pipeline/transforms/metainject/messages/messages_en_US.properties
@@ -46,6 +46,7 @@ MetaInject.Name=ETL metadata injection
 MetaInject.SourceFieldIsNotDefined.Message=Source field ''{0}'' is not defined in ''{1}'' pipeline!
 MetaInject.SourceTransformIsNotAvailable.Message=Source transform ''{0}'' is not available in ''{1}'' pipeline!
 MetaInject.TargetKeyIsNotDefined.Message=Target key ''{0}'' is not defined in ''{1}'' pipeline!
+MetaInject.TargetKeyNotFound.Warning=WARNING: injection target key ''{0}'' was not found in transform ''{1}'' and is ignored. It may have been removed in a newer version of Apache Hop.
 MetaInject.TargetTransformIsNotDefined.Message=Target transform ''{0}'' is not defined in ''{1}'' pipeline!
 MetaInject.TargetTransformIsNotUsed.Message=Target transform ''{0}'' is not used in ''{1}'' pipeline!
 MetaInjectDialog.Browse.Label=Browse...
diff --git a/plugins/transforms/metainject/src/test/java/org/apache/hop/pipeline/transforms/metainject/MetaInjectTest.java b/plugins/transforms/metainject/src/test/java/org/apache/hop/pipeline/transforms/metainject/MetaInjectTest.java
index 09d69dc333..8c41d5d922 100644
--- a/plugins/transforms/metainject/src/test/java/org/apache/hop/pipeline/transforms/metainject/MetaInjectTest.java
+++ b/plugins/transforms/metainject/src/test/java/org/apache/hop/pipeline/transforms/metainject/MetaInjectTest.java
@@ -234,6 +234,45 @@ class MetaInjectTest {
     assertEquals("resolved-value", buffer.getBuffer().getFirst()[0]);
   }
 
+  /**
+   * Regression test: a mapping to a target key that no longer exists in the template transform
+   * (e.g. an option removed in a newer Hop version, such as CSV Input's {@code INPUT_IF_NULL}) must
+   * NOT fail the whole injection. The mapping is logged as a warning and skipped, so a pipeline
+   * built against an older Hop version keeps running. Before the fix this threw a
+   * HopTransformException and the transform aborted.
+   */
+  @Test
+  void collectDataForOneMapping_unknownTargetKey_warnsInsteadOfThrowing() {
+    MetaInjectMapping mapping = new MetaInjectMapping();
+    mapping.setTargetTransformName(TEST_TARGET_TRANSFORM_NAME);
+    mapping.setTargetAttributeKey("INPUT_IF_NULL"); // a key that no longer exists in the target
+    mapping.setTargetDetail(true);
+    mapping.setSourceTransformName(null);
+    mapping.setSourceField("anything");
+
+    Map<String, Set<String>> injectionKeyGroupMap = new HashMap<>(); // key is in no group
+    Map<String, List<MetaInject.GroupColumn>> groupColumnsMap = new HashMap<>();
+    Map<String, RowBuffer> injectionGroupData = new HashMap<>();
+    Map<String, Object> injectionKeyData = new HashMap<>();
+
+    metaInject.getData().rowMap = new HashMap<>();
+
+    assertDoesNotThrow(
+        () ->
+            metaInject.collectDataForOneMapping(
+                TEST_TARGET_TRANSFORM_NAME,
+                mapping,
+                injectionKeyGroupMap,
+                groupColumnsMap,
+                injectionGroupData,
+                injectionKeyData,
+                InjectableTestTransformMeta.class));
+
+    // The unknown key is skipped: nothing is collected for injection.
+    assertTrue(injectionKeyData.isEmpty());
+    assertTrue(injectionGroupData.isEmpty());
+  }
+
   /**
    * Regression test for <a href="https://github.com/apache/hop/issues/7246">#7246</a>: when an
    * injection group mixes a streamed key and a constant key, the constant value must be merged into