You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Daniel Stieglitz (Jira)" <ji...@apache.org> on 2022/08/26 12:51:00 UTC

[jira] [Assigned] (NIFI-10396) Expression Language jsonPath throws error instead of returning empty string when subject is invalid JSON

     [ https://issues.apache.org/jira/browse/NIFI-10396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Stieglitz reassigned NIFI-10396:
---------------------------------------

    Assignee: Daniel Stieglitz

> Expression Language jsonPath throws error instead of returning empty string when subject is invalid JSON
> --------------------------------------------------------------------------------------------------------
>
>                 Key: NIFI-10396
>                 URL: https://issues.apache.org/jira/browse/NIFI-10396
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.17.0
>            Reporter: Daniel Stieglitz
>            Assignee: Daniel Stieglitz
>            Priority: Major
>         Attachments: JsonPathInvalidJsonYieldsFlowFiles.xml
>
>
> Per the [Expression Language documentation|https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#jsonpath] for jsonPath "An empty string is generated if the Subject does not contain valid JSON, the _jsonPath_ is invalid, or the path does not exist in the Subject." Further in the documentation it states "An empty subject value or a subject value with an invalid JSON document results in an exception bulletin." This would seem to indicate with invalid JSON an empty string is returned and the processor which is handling the Expression Language will get an empty string and not have to yield any flow files. Attached is a template which indicates that instead of a returned empty string, an exception is thrown and the processor is yielding flow files causing its queue to backup.
> The attached template [^JsonPathInvalidJsonYieldsFlowFiles.xml] 
> uses a RouteOnAttributeProcessor to determine whether an attribute value is valid JSON or not. Two Expression Language expressions are used both of which use JsonPath of $ (which should return the whole JSON document) chained with isEmpty():not() or isEmpty() to determine if the attribute value is valid JSON or not.
> Note how the flow file with a valid JSON attribute is routed correctly while the flow file with invalid JSON is yielded and not routed correctly. Instead of routing to the invalid relationship the flow files are backing up in the queue.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)