Andrea Cosentino created CAMEL-24512:
----------------------------------------
Summary: camel-spring-boot - error.message is overwritten when
several health checks report DOWN
Key: CAMEL-24512
URL: https://issues.apache.org/jira/browse/CAMEL-24512
Project: Camel
Issue Type: Bug
Components: camel-spring-boot
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
Fix For: 4.23.0
When several health checks report DOWN, only the last error message survives in
the actuator output.
{{CamelHealthCheckIndicator.doHealthCheck}} loops over every result and passes
the same {{Health.Builder}} to
{{CamelHealthHelper.applyHealthDetail}}:
{code:java}
for (HealthCheck.Result result : results) {
...
builder.withDetail(result.getCheck().getId(), result.getState().name());
CamelHealthHelper.applyHealthDetail(builder, result, exposureLevel);
{code}
{{applyHealthDetail}} writes the message to a flat, top-level key:
{code:java}
result.getError().ifPresent(error -> {
builder.withDetail("error.message", error.getMessage());
{code}
Spring Boot's {{Health.Builder.withDetail}} is a {{Map.put}}, so each failing
check overwrites the previous
one's {{error.message}}. With two DOWN checks the output carries only the
second message, while the per-check
{{<id>.data}} maps correctly stay separate:
{code}
error.message=second-message
first.data={...}
second.data={...}
{code}
The first message is only recoverable because the per-check {{data}} map also
carries {{error.stacktrace}},
which embeds it - so the message is not strictly lost today, but it is not
addressable per check either, and
the top-level key is misleading when more than one check fails.
*Proposal*
Write {{error.message}} into the check-scoped {{data}} map alongside the other
per-check entries, keeping the
top-level key as well if compatibility requires it. Add a regression test with
two distinct DOWN results
asserting that each message is retrievable under its own check id.
Reported by Luigi De Masi during review of CAMEL-24499.
----
_This issue was drafted by Claude Code on behalf of Andrea Cosentino._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)