[ 
https://issues.apache.org/jira/browse/NIFI-10396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17634567#comment-17634567
 ] 

Daniel Stieglitz commented on NIFI-10396:
-----------------------------------------

[~mattyb149] Yeah I think you can close this. NIFI-10612 was meant to short 
circuit if the attribute value was not JSON before running jsonPath and failing.

> 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: 
> 0001-NIFI-10396-Refactored-code-to-have-jsonPath-jsonPath.patch, 
> 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)

Reply via email to