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

Adam Taft commented on NIFI-11156:
----------------------------------

One more (maybe too obvious) solution just came to me. Arguably this might even 
be the best and smallest thing we could do.

If we update StandardSchemaValidator to include the proper nested message when 
it throws, then we'd be back to square one. Specifically, line 56 becomes:

throw new ProcessingException("Validation failed: " + e.getMessage(), e);

In my opinion, since StandardSchemaValidator and ProcessingException 
effectively masked the existing error, it's ideal that these classes are the 
ones made to fix the issue. The one line change above does it.

Additionally, as a response to the comment about "parsing" the error attribute. 
The use case here is not about parsing the message, it's about (as stated) 
logging the error message. Logging, or generating a support ticket, or 
evaluating the flowfile in a queue, etc. The validation messages are only human 
readable, yes, but that's the point.

A classic use case for this is when the failure condition results in a ticket 
generated for a help system. If you just have some generic phrase, is at is 
today, "Validation failed", it gives no more context for debugging or triaging 
the incident.

At that point, the only thing you can do with the flowfile is write it to disk 
or somehow capture the content so that you can run it through xmllint or 
equivalent external from NiFi. That's the pain being avoided with this fix, 
very much about logging or viewing the validation error message.

> ValidateXml Processor - validatexml.invalid.error = Validation failed
> ---------------------------------------------------------------------
>
>                 Key: NIFI-11156
>                 URL: https://issues.apache.org/jira/browse/NIFI-11156
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: 1.19.1
>         Environment: CentOS 7.5, RedHat 7.9
> Temurin - 11.0.17+8
>            Reporter: Bilal
>            Priority: Minor
>
> _NiFi_ environment was upgraded from 1.15.1 to 1.19.1. The following 
> situation has occurred with the _ValidateXml_ processor:
> _ValidateXml_ processor works correctly on 1.15.1 and 
> _validatexml.invalid.error_ attribute gives an detail information about the 
> error.
> _ValidateXml_ processor works on 1.19.1 but _validatexml.invalid.error_ 
> attribute does not give an detail information about the _error. 
> validatexml.invalid.error_ attriubute only contains “{_}Validation failed{_}” 
> text.
> Similar problem was talked in cloudera community and Eduu said that:
> ===========
> Hi 
> [@ChuckE|https://community.cloudera.com/t5/user/viewprofilepage/user-id/98065]
>  using NiFi 1.15.2 seems to add the error detail in the 
> "validatexml.invalid.error" attribute.
> For example --> "cvc-minLength-valid: Value '' with length = '0' is not 
> facet-valid with respect to minLength '1' for type 'HotelCode"
> This seems to be an issue starting from NiFi 1.16.3, maybe a bug?
> You can use NiFi 1.15.2 or custom code as 
> [@SAMSAL|https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381]
>  suggested.
> ===========
> Ref: [How to get the reason for invalid 
> XML|[https://community.cloudera.com/t5/Support-Questions/How-to-get-the-reason-for-invalid-XML/m-p/348767/highlight/true#M235443]]



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

Reply via email to