Federico Mariani created CAMEL-23983:
----------------------------------------

             Summary: camel-yaml-dsl-maven-plugin - @YamlProperty flag emission 
broken: withRequired(isDeprecated) typo drops required/deprecated on non-String 
properties, secret never emits format=password
                 Key: CAMEL-23983
                 URL: https://issues.apache.org/jira/browse/CAMEL-23983
             Project: Camel
          Issue Type: Bug
          Components: camel-yaml-dsl
    Affects Versions: 4.21.0
            Reporter: Federico Mariani


Two related codegen bugs in {{@YamlProperty}} annotation emission in 
{{dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin}}:

h3. 1. withRequired(isDeprecated(field)) typo (11 sites)

In {{GenerateYamlDeserializersMojo.java}} (lines 1027, 1042, 1060, 1078, 1094, 
1110, 1126, 1190, 1216, 1232, 1250) the builder chain is:

{code:java}
.withRequired(isRequired(field))
.withRequired(isDeprecated(field))   // should be withDeprecated
{code}

{{AnnotationBuilder.withRequired}} is a plain setter, so the second call 
overwrites the required flag with the deprecation flag. The String branches 
(lines 999, 1147, 1162, 1173) use the correct {{withDeprecated}} pattern, 
confirming the intent. Affected branches: enum, metadata-enum, byte[], 
boolean/int/long/double primitives, Class, numeric/Boolean wrappers, and the 
default object branch.

Effect: any *required non-String* model attribute silently loses its required 
constraint in the generated deserializers and in the published 
{{camelYamlDsl.json}} (e.g. {{ParamDefinition.type}} is 
{{@XmlAttribute(required = true)}} but the schema lists only {{name}} as 
required), and deprecated fields in these branches are never marked deprecated. 
Regression introduced by the CAMEL-19709 refactor ({{a52062950297}}); the 
pre-refactor code correctly emitted {{required}}.

h3. 2. secret -> format="password" propagation is dead end-to-end

* {{YamlProperties.AnnotationBuilder.withIsSecret(JsonNode)}} 
({{support/YamlProperties.java:138-150}}) returns early unless 
{{node.isTextual()}}, but the catalog JSON {{secret}} attribute is a *boolean* 
— so {{format = "password"}} can never be emitted (0 occurrences in the 
generated {{ModelDeserializers.java}}). Compare {{withDefaultValue}}, which 
correctly accepts textual/number/boolean.
* Additionally, {{GenerateYamlDeserializersMojo.java:912,951}} pass 
{{descriptor.defaultValue(name)}} into {{withIsSecret}} instead of 
{{descriptor.isSecret(name)}} (copy-paste), which would wrongly mark properties 
with a textual default of "true" as secret once the boolean check is fixed.

Fixing either bug requires regenerating {{ModelDeserializers.java}} and the 
YAML schema, and downstream consumers of {{camelYamlDsl.json}} (validators, 
editors/LSP) will start seeing the correct 
{{required}}/{{deprecated}}/{{password}} metadata.

_Filed by Claude Code on behalf of Croway._



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

Reply via email to