Federico Mariani created CAMEL-23990:
----------------------------------------

             Summary: camel-yaml-dsl-validator - error messages fed to new 
MessageFormat(...): a '{' in the parse error crashes the validator instead of 
reporting
                 Key: CAMEL-23990
                 URL: https://issues.apache.org/jira/browse/CAMEL-23990
             Project: Camel
          Issue Type: Bug
          Components: camel-yaml-dsl-validator-maven-plugin
    Affects Versions: 4.21.0
            Reporter: Federico Mariani


All three catch blocks in the validator build {{new 
MessageFormat(e.getClass().getName() + ": " + e.getMessage())}}:

* {{dsl/camel-yaml-dsl/camel-yaml-dsl-validator/.../YamlParser.java:43-46}}
* {{.../YamlValidator.java:69-72}}
* {{.../CamelYamlParser.java:101-104}}

{{MessageFormat}}'s constructor parses the pattern eagerly: an unmatched {{{}} 
throws {{IllegalArgumentException}}. SnakeYAML/Jackson-YAML parse errors embed 
a raw snippet of the offending source line in the message, so validating a file 
containing e.g. {{foo: {bar}} (unclosed flow mapping) makes the *error reporter 
itself* throw inside the catch block; {{validate()}} propagates the exception 
and {{ValidateMojo}} aborts the whole build with {{MojoExecutionException}} 
even with {{failOnError=false}}.

Additionally, apostrophes in messages (very common in Jackson errors, e.g. 
{{Unexpected character ('}' ...)}}) are MessageFormat quote characters, so 
reported messages get silently mangled.

Fix: escape the message, or pass it as a format *argument* to a constant 
pattern instead of using it as the pattern.

_Filed by Claude Code on behalf of Croway._



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

Reply via email to