You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2026/09/11 20:59:00 UTC
[jira] [Commented] (CAMEL-24694) YAML DSL validator rejects scalar values the runtime accepts (quoted booleans/numbers and placeholders at typed attributes)
[ https://issues.apache.org/jira/browse/CAMEL-24694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18114471#comment-18114471 ]
Claus Ibsen commented on CAMEL-24694:
-------------------------------------
Correction to the suggested fix after discussion: the schema must keep its real types (boolean, integer, number, string) because tooling (Kaoto forms, TUI completion, catalog docs) relies on them. Do NOT emit type unions in the schema generator.
The leniency belongs in the validator, which has to know that Camel accepts a string at any typed attribute and converts it at load time (type converters, and property placeholders).
Proposed fix in camel-yaml-dsl-validator ({{YamlValidator}}, the {{SchemaRegistryConfig.builder()}} call around line 352):
# Enable the library's type-loose mode ({{SchemaRegistryConfig.isTypeLoose()}} exists in networknt json-schema-validator 2.0.1), so {{"true"}} at a boolean attribute and {{"5"}} / {{5}} at an integer or numeric-string attribute validate.
# Add a pre-pass over the YAML node tree: any scalar string containing a property placeholder ({{{{...}}}}) at a typed attribute is accepted (replace it with a dummy of the expected type before validation, or skip the type check for that node), and report the original position on other errors.
# Keep the strictness for everything else: unknown properties, wrong structure, enum values.
The docs can still be normalised to the natural scalar form (tracked in CAMEL-24693), but the validator must accept the string forms because the runtime does.
> YAML DSL validator rejects scalar values the runtime accepts (quoted booleans/numbers and placeholders at typed attributes)
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24694
> URL: https://issues.apache.org/jira/browse/CAMEL-24694
> Project: Camel
> Issue Type: Bug
> Components: camel-yaml-dsl
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
>
> h3. Problem
> The generated YAML DSL JSON schema ({{camelYamlDsl.json}}) types scalar attributes from the model's {{@Metadata(javaType=...)}} rather than from the Java field type. Most EIP attributes are declared as {{String}} in the model precisely so that property placeholders ({{{{myValue}}}}) can be used, and the YAML deserializer converts the text at runtime. The schema is therefore stricter than the runtime, in both directions:
> * {{SplitDefinition.parallelProcessing}} and {{streaming}} are {{String}} fields with {{javaType=java.lang.Boolean}}; the schema emits {{boolean}}, so {{parallelProcessing: "true"}} is rejected ("string found, boolean expected") although {{camel run}} starts the route.
> * {{ThrottleDefinition.timePeriodMillis}} is a {{String}} field with {{javaType=java.time.Duration}}; the schema emits {{string}}, so {{timePeriodMillis: 10000}} is rejected ("integer found, string expected") although {{camel run}} starts the route.
> * {{RestConfigurationDefinition.port}} and resilience4j {{waitDurationInOpenState}} behave the same way (integer rejected, string required).
> h3. Why it matters
> Every consumer of the schema refuses input the runtime accepts: {{camel validate yaml}}, the Camel TUI save-time validation and its {{tui_write_file}} / {{tui_validate_source}} MCP tools, camel-jbang-mcp {{camel_validate_yaml_dsl}}, IDE plugins and Kaoto. On 2026-09-11, 41 of the 280 YAML examples in the EIP documentation failed validation for this reason alone, and in an AI-assisted editing benchmark two of the four corrections a frontier model needed, and a large share of a local model's refused writes, were this exact class ("integer found, string expected" / "string found, boolean expected").
> h3. Suggested fix (generator, not hand edits)
> In the schema generator, for any model attribute whose Java field type is {{String}}, emit a type union that accepts the string form as well as the natural scalar: {{"type": ["string", "boolean"]}}, {{["string", "integer"]}}, {{["string", "number"]}}. Keep the natural scalar first so completion and documentation still show the intended type. Since placeholders make every such attribute a valid string at runtime, this only removes false rejections; the runtime type converter still reports genuinely wrong values.
> Optionally normalise the doc examples to the natural scalar form (see the companion samples issue), but the schema should accept both.
> h3. Reproducer
> {code}
> - route:
> from:
> uri: timer:tick?period=1000
> steps:
> - split:
> parallelProcessing: "true"
> tokenize: ","
> steps:
> - log: "${body}"
> {code}
> {{camel validate yaml}}: {{/0/route/from/steps/0/split/parallelProcessing: string found, boolean expected}}. {{camel run}}: Routes startup (total:1).
> Related: CAMEL-24692 (simple validator placeholder bug).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)