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

Daniel Stieglitz edited comment on NIFI-10396 at 9/19/22 2:31 PM:
------------------------------------------------------------------

[~mattyb149] thank you for taking the time to look over and comment on my 
patch.  I am not sure what you meant by

"The former may be handled by an upstream processor (perhaps ConvertRecord or 
UpdateRecord or a scripted processor/reader)"

Are you suggesting changes to multiple processors or only a handful so they 
could handle when there are Subjects with non-empty invalid JSON? I would think 
it should apply to any processor that can handle Expression language. 

Wouldn't a new Expression Language method (e.g. isJson) that would take a 
string argument and determine if that string is valid JSON or not, be easier to 
implement than to have to change multiple processors to handle the exception 
where the JSON is invalid?


was (Author: JIRAUSER294662):
[~mattyb149] thank you for taking the time to look over and comment on my 
patch.  I am not sure what you meant by

"The former may be handled by an upstream processor (perhaps ConvertRecord or 
UpdateRecord or a scripted processor/reader)"

Are you suggesting changes to multiple processors or only a handful so they 
could handle when there are Subjects with non-empty invalid JSON? I would think 
it should apply to any processor that can handle Expression language. Please 
clarify. Thanks!

> 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