nanjeshramesh opened a new pull request, #11735: URL: https://github.com/apache/nifi/pull/11735
<!-- Licensed to the Apache Software Foundation (ASF) under one or more --> <!-- contributor license agreements. See the NOTICE file distributed with --> <!-- this work for additional information regarding copyright ownership. --> <!-- The ASF licenses this file to You under the Apache License, Version 2.0 --> <!-- (the "License"); you may not use this file except in compliance with --> <!-- the License. You may obtain a copy of the License at --> <!-- http://www.apache.org/licenses/LICENSE-2.0 --> <!-- Unless required by applicable law or agreed to in writing, software --> <!-- distributed under the License is distributed on an "AS IS" BASIS, --> <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <!-- See the License for the specific language governing permissions and --> <!-- limitations under the License. --> # Summary [NIFI-16001](https://issues.apache.org/jira/browse/NIFI-16001) `PropertyContext.create_python_property_value` checks whether a property value 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 for a full evaluation. That check used `re.match`, which only anchors at the start of the string, so `${attr}_suffix` matched on the `${attr}` prefix and took the fast path anyway, silently dropping `_suffix`. Any property on a Python processor whose value referenced an attribute with literal text before or after it (for example `${greeting}, welcome!`) was truncated down to just the attribute's value. * Switch the trivial and escaped/quoted attribute reference checks in `PropertyContext.create_python_property_value` from `re.match` to `re.fullmatch`. A bare `${attr}` or `${'attr'}` still takes the fast path exactly as before; anything with surrounding literal text now falls through to full expression evaluation, which already handles this correctly. * Adds a unit test module (`nifi-python-extension-api/src/test/python/nifiapi/TestPropertyContext.py`) covering the trivial and escaped forms, with and without surrounding text, and wires it into the existing `python-unit-tests` Maven profile the same way `nifi-python-framework` already does. * Adds a system test case to `PythonProcessorIT` that exercises the fix through an actual `WritePropertyToFlowFile` Python processor. # Tracking ### Issue Tracking - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created ### Pull Request Tracking - [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000` - [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000` - [ ] Pull request contains commits signed with a registered key indicating `Verified` status ### Pull Request Formatting - [x] Pull Request based on current revision of the `main` branch - [x] Pull Request refers to a feature branch with one commit containing changes # Verification ### Build - [x] `mvn test -pl nifi-framework-bundle/nifi-framework-extensions/nifi-py4j-framework-bundle/nifi-python-extension-api -am -P python-unit-tests`: 7 tests, all pass - [x] JDK 21 (compiled with `--release 21`) - [ ] JDK 25 - [x] `mvn test-compile -pl nifi-system-tests/nifi-system-test-suite -am`: compiles clean - [x] `checkstyle:check` on `nifi-system-test-suite`: 0 violations - [x] `apache-rat-plugin:check` on `nifi-python-extension-api`: 0 unapproved I could not run the new `PythonProcessorIT` case itself locally, since NiFi system tests need the full launcher/instance harness; that one needs CI. I did confirm the unit test fails without the fix and passes with it (reverted the one-line change locally, reran, then restored it). ### Licensing - [x] No new dependencies ### Documentation - N/A, no user-facing documentation change -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
