CAMEL-24848: Fix mail useHeader* option defaults - #26628
Brijesh-Thakkar wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Updates Camel Mail metadata so four header-override options advertise their documented default of true.
Changes:
- Adds
defaultValue = "true"to four@UriParamannotations. - Regenerates metadata for SMTP, SMTPS, POP3, POP3S, IMAP, and IMAPS.
| File | Description |
|---|---|
| components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java | Updated as part of this pull request. |
| components/camel-mail/src/generated/resources/META-INF/org/apache/camel/component/mail/smtps.json | Updated as part of this pull request. |
| components/camel-mail/src/generated/resources/META-INF/org/apache/camel/component/mail/smtp.json | Updated as part of this pull request. |
| components/camel-mail/src/generated/resources/META-INF/org/apache/camel/component/mail/pop3s.json | Updated as part of this pull request. |
| components/camel-mail/src/generated/resources/META-INF/org/apache/camel/component/mail/pop3.json | Updated as part of this pull request. |
| components/camel-mail/src/generated/resources/META-INF/org/apache/camel/component/mail/imaps.json | Updated as part of this pull request. |
| components/camel-mail/src/generated/resources/META-INF/org/apache/camel/component/mail/imap.json | Updated as part of this pull request. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @UriParam(label = "producer,advanced,security", security = "insecure:ssl") | ||
| private boolean useJavaMailSessionPropertiesFromHeaders; | ||
| @UriParam(label = "producer") | ||
| @UriParam(defaultValue = "true", label = "producer") |
gnodet-bot
left a comment
There was a problem hiding this comment.
The intention here is right — the generated metadata is inconsistent with the field declarations — but the diagnosis is inverted. This PR treats the current defaultValue: false in the JSON files as a bug to fix; it's actually the correct runtime state.
See commit e027f1836524c (CAMEL-23747, June 2026): the defaults were deliberately changed from true to false for secure-by-default behaviour. Allowing untrusted Exchange headers (e.g. from an HTTP consumer) to override configured mail recipients, sender, subject, and reply-to by default enables email redirection attacks. The change also removed = true from the field initializers and defaultValue = "true" from the @UriParam annotations at the same time.
The actual documentation bug is the opposite: the @param Javadoc on the four setters still says "Defaults to true." — which is now wrong. That text needs to be updated to say "Defaults to false." The generated JSON files already report defaultValue: false correctly and must not be changed.
So the fix needed is:
- Update the four Javadoc descriptions (in
MailConfiguration.java) to remove "Defaults to true." — change to "Defaults to false. Set to true to allow..." (reversing the opt-in language) - Regenerate the JSON metadata (the descriptions in the JSON files embed the same "Defaults to true." text, so they also need to change after the Javadoc is fixed)
- No changes to
@UriParam(defaultValue = ...)— those should remain absent/false
The PR checkbox confirming mvn clean install -DskipTests was run locally is unchecked with an explanation that the build failed in an unrelated module. Please attempt a mvn install -DskipTests -pl components/camel-mail scoped build at minimum before re-submitting.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| @UriParam(label = "producer,advanced,security", security = "insecure:ssl") | ||
| private boolean useJavaMailSessionPropertiesFromHeaders; | ||
| @UriParam(label = "producer") | ||
| @UriParam(defaultValue = "true", label = "producer") |
There was a problem hiding this comment.
e027f1836524c (CAMEL-23747) deliberately removed defaultValue = "true" here and reset the field initializer to false for secure-by-default. Adding it back undoes that security hardening without any corresponding = true on the field — the annotation attribute is documentation metadata only and does not affect the runtime value.
The actual bug is in the Javadoc: the setter descriptions for all four options still say "Defaults to true." That text should be updated to reflect the current false default.
|
The useHeader* defaults are correct as-is, false is correct and introduced by CAMEL-23747, and it's documented as a breaking change in the 4.21 upgrade guide. Changing defaultValue to true would make the catalog, IDE completion and the generated starter disagree with the code, and regenerating camel-spring-boot would silently flip Spring Boot users back to header-overrides-enabled. Could you revert the MailConfiguration annotation change and instead update:
|
001e4bf to
f47e441
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
The re-push fully addresses all feedback from the previous review.
Prior findings — status:
- ✅
@UriParamannotations: nodefaultValue = "true"added — the four fields remain plain@UriParam(label = "producer")with nodefaultValueattribute, so the annotation processor correctly infersfalse. Runtime behaviour unchanged. - ✅ JSON metadata
defaultValuefield: stays atfalseacross all six descriptor files (imap, imaps, pop3, pop3s, smtp, smtps). - ✅ JSON description strings: correctly updated from "Defaults to true. Set to false to always use..." → "Defaults to false. Set to true to let message headers override..." — matches the actual runtime default.
- ✅
MailConfiguration.javasetter Javadoc: all four updated to "Defaults to false. Set to true to let..." — no longer contradicts the code. - ✅
mail-component.adoctable: Default column now showsfalse; column header changed to "Effect when set totrue"; footer sentence updated to drop the now-incorrect "existing behaviour is preserved" phrasing.
No issues with field initializers, annotation processor outputs, or Spring Boot catalog consistency. The change is a doc/metadata-only fix with no runtime impact.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
oscerd
left a comment
There was a problem hiding this comment.
Thanks — the change itself is correct (the useHeader* options do default to false, and the stale descriptions needed exactly this fix). Heads-up on why CI is red: the build (25) job fails at "Fail if there are uncommitted changes" because the description change was regenerated only into the module-level files, not the catalog and DSL layers. A @UriParam description change propagates to all three.
Still needing regeneration and commit:
- Catalog copies:
catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/{imap,imaps,pop3,pop3s,smtp,smtps}.jsonandcatalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/mail-component.adoc - DSL builders:
dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/{Imap,Imaps,Pop3,Pop3s,Smtp,Smtps}ComponentBuilderFactory.javaanddsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MailEndpointBuilderFactory.java
Note that -Dquickly skips the DSL generation, which is likely why these were missed. A normal build that reaches the dsl and catalog modules regenerates them (build components/camel-mail, then the dsl/catalog modules) — commit the updated files and the uncommitted-changes check will pass. Once that's in, this looks good to me.
This is a rules-and-conventions review and does not replace specialized AI review tools or static analysis.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of oscerd
davsclaus
left a comment
There was a problem hiding this comment.
Thanks for the fix, @Brijesh-Thakkar - the content is right: Javadoc, the adoc table and the component JSON descriptions now all say false, which matches the CAMEL-23747 secure-by-default change, and there is no runtime change.
+1 to what @oscerd wrote above: the only thing keeping CI red is that the same description change also has to be regenerated into the catalog copies (catalog/camel-catalog/src/generated/...) and the component-dsl / endpoint-dsl builders under dsl/. I checked on main and there are 6 of those generated files still carrying the old "Defaults to true" text, so once those are regenerated and committed this is good to go.
Claude Code on behalf of @davsclaus
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
gnodet-bot
left a comment
There was a problem hiding this comment.
The re-push completes the regeneration from the previous round.
What changed in this push: The catalog/docs/mail-component.adoc (generated catalog copy) and MailEndpointBuilderFactory.java were not regenerated in the prior push — this commit adds them, propagating the corrected descriptions throughout all generated artifacts.
Correctness check on the new additions:
catalog/camel-catalog/.../docs/mail-component.adoc: table column flipped to "Effect when set totrue", defaults corrected tofalse— matches the source adoc.MailEndpointBuilderFactory.java: all 8 Javadoc blocks (4 options × 2 overloads each) updated consistently to "Defaults to false. Set to true to let..." — matchesMailConfiguration.javasetters and the JSON descriptors.
No logic changes. All generated artifacts are now consistent with the field declarations (private boolean useHeader* — bare Java boolean = false). No issues.
This review was generated by an AI agent, Hermès on behalf of @gnodet.

Description
The Mail component documentation incorrectly stated that the
useHeaderRecipients,useHeaderFrom,useHeaderSubject, anduseHeaderReplyTooptions default totrue.These options were intentionally changed to default to
falsebyCAMEL-23747 as part of the secure-by-default behavior. However, the
setter Javadocs and generated component documentation still described
the old defaults.
This change:
falsedefaults.mail-component.adocto document the current defaults andthe behavior when these options are explicitly set to
true.defaultValue: falseand corrected descriptions.
Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.The full root build was not completed. A scoped Camel Mail build was
successfully run with:
./mvnw install -DskipTests -pl components/camel-mailThe focused test also passed:
MailHeaderOverrideOptionsTest: 11 tests, 0 failures, 0 errors.All generated Mail component metadata changes are included in this PR.
AI-assisted contributions
This PR was prepared with assistance from OpenCode using the Nemotron 3.5
model, operated by Brijesh Thakkar.