[
https://issues.apache.org/jira/browse/NIFI-16001?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18126433#comment-18126433
]
ASF subversion and git services commented on NIFI-16001:
--------------------------------------------------------
Commit 2d34148940e5b2007b0c40fc9efc71faf383fce8 in nifi's branch
refs/heads/main from Nanjesh Ramesh
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=2d34148940e ]
NIFI-16001 Fix property value truncation around an EL attribute reference in
Python processors (#11735)
PropertyContext.create_python_property_value detects a property value that is
entirely a single attribute reference, such as "${attr}", so
PythonPropertyValue.evaluateAttributeExpressions can take a fast path and look
the attribute up directly instead of calling back into the Java expression
language engine. That check used re.match, which only anchors at the start of
the string, so a value like "${attr}_suffix" matched on the "${attr}" prefix
and took the fast path anyway, silently dropping the "_suffix" literal text.
Any WritePropertyToFlowFile-style property whose value referenced an attribute
with any literal text before or after it was truncated down to just the
attribute's value.
Switch both the trivial and the escaped/quoted reference checks to
re.fullmatch, which requires the whole string to match. A bare "${attr}" or
"${'attr'}" still takes the fast path exactly as before; anything with
surrounding text now falls through to full expression evaluation, which
already handles this correctly.
Added a unit test module for this class under
nifi-python-extension-api/src/test/python, wired into the existing
python-unit-tests Maven profile, and a system test case in PythonProcessorIT
that exercises the fix through an actual Python processor.
> String around an expression language in python processor is cut
> ---------------------------------------------------------------
>
> Key: NIFI-16001
> URL: https://issues.apache.org/jira/browse/NIFI-16001
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 2.9.0
> Environment: Podman 5.8.2 with official Nifi image
> Reporter: Fabian Reiber
> Priority: Minor
> Time Spent: 50m
> Remaining Estimate: 0h
>
> I try to use an expression language in a python processor. It works pretty
> fine, but when I use something like "${my_attribute}_foo_bar" (where
> "my_attribute" has the value "hello") as the property value, everything after
> the expression is cut. Just "hello" is shown. If I use a parameter from the
> context like "#\{my_attribute}_foo_bar", it works and the value is
> "hello_foo_bar". I was wondering, if I am doing something wrong. But I found
> the
> [WritePropertyToFlowFile|https://github.com/apache/nifi/blob/rel/nifi-2.9.0/nifi-extension-bundles/nifi-py4j-extension-bundle/nifi-python-test-extensions/src/main/resources/extensions/WritePropertyToFlowFile.py]
> processor and tried it. It shows the same behaviour.
> It can be workarounded with "${my_attribute:append('_foo_bar')}".
--
This message was sent by Atlassian Jira
(v8.20.10#820010)