markap14 commented on a change in pull request #4088: NIFI-7197 - In-place 
replacement in LookupRecord processor
URL: https://github.com/apache/nifi/pull/4088#discussion_r387733336
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/LookupRecord.java
 ##########
 @@ -214,24 +227,36 @@ protected PropertyDescriptor 
getSupportedDynamicPropertyDescriptor(final String
         }
 
         final Set<String> requiredKeys = 
validationContext.getProperty(LOOKUP_SERVICE).asControllerService(LookupService.class).getRequiredKeys();
-        final Set<String> missingKeys = requiredKeys.stream()
-            .filter(key -> !dynamicPropNames.contains(key))
-            .collect(Collectors.toSet());
 
-        if (!missingKeys.isEmpty()) {
-            final List<ValidationResult> validationResults = new ArrayList<>();
-            for (final String missingKey : missingKeys) {
-                final ValidationResult result = new ValidationResult.Builder()
-                    .subject(missingKey)
-                    .valid(false)
-                    .explanation("The configured Lookup Services requires that 
a key be provided with the name '" + missingKey
-                        + "'. Please add a new property to this Processor with 
a name '" + missingKey
-                        + "' and provide a RecordPath that can be used to 
retrieve the appropriate value.")
-                    .build();
-                validationResults.add(result);
+        if(validationContext.getProperty(IN_PLACE_REPLACEMENT).asBoolean()) {
+            // it must be a single key lookup service
+            if(requiredKeys.size() != 1) {
+                return Collections.singleton(new ValidationResult.Builder()
+                        .subject(LOOKUP_SERVICE.getDisplayName())
+                        .valid(false)
+                        .explanation("The configured Lookup Services should 
only require one key when in-place replacement is set to true.")
 
 Review comment:
   Would also recommend updating this explanation if updating the "In-Place 
Replacement" property to be a strategy. Also would even recommend being a bit 
more explicit in telling the user that the configured Lookup Service is not 
compatible with the selected strategy. As written, it sounds like the service 
is doing something wrong because the service "should only require one key".

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to