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

Claus Ibsen updated CAMEL-24837:
--------------------------------
    Fix Version/s: 4.23.0

> camel validate yaml: say in plain words what a YAML indentation error is, 
> instead of the raw snakeyaml message
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24837
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24837
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jbang, camel-yaml-dsl
>            Reporter: Claus Ibsen
>            Assignee: Adriano Machado
>            Priority: Major
>             Fix For: 4.23.0
>
>
> When a YAML route file has a list item indented differently from the first 
> item of the same list, {{camel validate yaml}} (and the camel-jbang-mcp 
> validation tool) return the raw parser message:
> {code}
> : com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.MarkedYAMLException: 
> while parsing a block mapping
>  in 'reader', line 28, column 27:
>                               when:
>                               ^
> expected <block end>, but found '-'
>  in 'reader', line 53, column 27:
>                               - expression:
>                               ^
>  at [Source: (StringReader); line: 53, column: 27]
> {code}
> Nobody who does not know snakeyaml can act on "expected <block end>, but 
> found '-'". What happened is: the list under {{when:}} (line 28) starts at 
> line 29 with an item indented to column 29, and line 53 has another {{- 
> expression:}} at column 27, so the parser thinks the mapping ended and finds 
> a stray list item.
> Suggested: catch {{MarkedYAMLException}} in the validator and translate the 
> common cases, keeping the line numbers:
> * "expected <block end>, but found '-'": "Line 53: this list item is indented 
> differently from the first item of the list that starts at line 29; every 
> item of a list must start in the same column."
> * "found unknown escape character": "Line 3: a backslash inside double quotes 
> is an escape; write the value in single quotes: 
> 'file:orders?include=.*\.json'" (a model wrote {{include=.*\.json}} in double 
> quotes in the same benchmark).
> * "mapping values are not allowed here": the usual "a colon in an unquoted 
> value".
> Found in the round-2 local-model benchmark on the camel-jbang-examples 
> ladder: the model got this message, validated the same unchanged content ten 
> more times, and never recovered. A person with a nested choice gets the same 
> message.



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

Reply via email to