Skip to content

NIFI-16616 Resolve Parameters when evaluating Search Context properties - #11955

Open
joewitt wants to merge 2 commits into
apache:mainfrom
joewitt:joewitt/NIFI-16616
Open

joewitt wants to merge 2 commits into
apache:mainfrom
joewitt:joewitt/NIFI-16616

Conversation

@joewitt

@joewitt joewitt commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • StandardSearchContext.getProperty() used ParameterLookup.EMPTY, so a Searchable processor calling evaluateAttributeExpressions() on a parameterized property lost the Parameter. ExecuteScript turned #{scripts.dir}/file.groovy into /file.groovy and logged FileNotFoundException during canvas search.
  • getValue() still returns the raw configured value, keeping the raw-form search behavior from NIFI-141. Script Body and other raw text in search results never include Parameter values.
  • Parameters resolve only during evaluateAttributeExpressions(), and only when the Parameter sensitivity matches the Property sensitivity, consistent with runtime resolution in AbstractComponentNode.isResolveParameter. A sensitive Parameter is never resolved into a non-sensitive Property.

Test plan

  • TestStandardSearchContext: resolves a matching Parameter on evaluation, keeps getValue() raw, and excludes mismatched sensitivity in both directions. The resolution test fails on main with expected </opt/scripts/file.groovy> but was </file.groovy>.
  • SearchableMatcherTest, PropertyMatcherTest
  • checkstyle:check pmd:check on nifi-web-api

JIRA: https://issues.apache.org/jira/browse/NIFI-16616

Made with Cursor

joewitt and others added 2 commits November 19, 2026 14:52
Co-authored-by: Cursor <cursoragent@cursor.com>
…rameters on evaluation

Co-authored-by: Cursor <cursoragent@cursor.com>
@joewitt joewitt changed the title NIFI-16616 Use effective property values in StandardSearchContext NIFI-16616 Resolve Parameters when evaluating Search Context properties Nov 19, 2026
@mcgilman

Copy link
Copy Markdown
Contributor

Reviewing...

@mcgilman
mcgilman self-requested a review November 20, 2026 20:03

@mcgilman mcgilman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up. Resolving parameters in the search context is the right layer, and keeping getValue() raw while resolving only on evaluation looks correct. The sensitivity filter is also necessary: without it, a bare #{sensitiveParam} on a non-sensitive property would resolve to the sensitive value.

Two small requests below: one for the class Javadoc, one for the tests.

Comment on lines +72 to +74
/**
* Resolves only Parameters whose sensitivity matches the sensitivity of the Property, consistent with Parameter resolution at runtime
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite consistent with runtime. At runtime, AbstractComponentNode.isResolveParameter keeps the entire raw value when any referenced parameter's sensitivity differs from the property's. This lookup filters each reference on its own, and expression language evaluates a filtered parameter to an empty value. For example, #{scripts.dir}/#{secret} on a non-sensitive property evaluates to /opt/scripts/ here, but runtime keeps the raw string. That configuration is already invalid, and the sensitive value is never substituted, so I don't think the behavior needs to change. The comment should describe what it does, though. Maybe something like:

Suggested change
/**
* Resolves only Parameters whose sensitivity matches the sensitivity of the Property, consistent with Parameter resolution at runtime
*/
/**
* Resolves only Parameters whose sensitivity matches the sensitivity of the Property. A reference to a Parameter with
* mismatched sensitivity evaluates to an empty value, so a sensitive Parameter value is never substituted into a non-sensitive Property.
*/

Comment on lines +98 to +114
@Test
void getPropertyEvaluatedExcludesSensitiveParameterForNonSensitiveProperty() {
when(processorNode.getRawPropertyValue(SCRIPT_FILE)).thenReturn("#{secret}");

final String evaluated = context.getProperty(SCRIPT_FILE).evaluateAttributeExpressions().getValue();

assertFalse(evaluated != null && evaluated.contains(SECRET_VALUE));
}

@Test
void getPropertyEvaluatedExcludesNonSensitiveParameterForSensitiveProperty() {
when(processorNode.getRawPropertyValue(PASSWORD)).thenReturn("#{scripts.dir}");

final String evaluated = context.getProperty(PASSWORD).evaluateAttributeExpressions().getValue();

assertFalse(evaluated != null && evaluated.contains("/opt/scripts"));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertFalse(evaluated != null && evaluated.contains(...)) passes for null, an empty string, the raw reference, or a truncated path, so it doesn't pin down the actual behavior. Could these assert the exact strings? For Script File:

  • #{secret} evaluates to ""
  • #{scripts.dir}/#{secret} evaluates to /opt/scripts/

Could you also add a case where processorNode.getParameterLookup() returns null? That's the common case of a processor whose group has no Parameter Context. #{scripts.dir}/file.groovy should evaluate to /file.groovy without throwing. The null guard in SensitivityMatchingParameterLookup handles this, but nothing currently tests it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants