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/28 08:09:00 UTC

[jira] [Resolved] (CAMEL-25020) camel-sql - observability still reports the CamelSqlQuery header when useMessageBodyForSql=true

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

Claus Ibsen resolved CAMEL-25020.
---------------------------------
    Resolution: Fixed

Fixed by https://github.com/apache/camel/pull/26885 (merged to main for 4.23.0).

_Claude Code on behalf of davsclaus_

> camel-sql - observability still reports the CamelSqlQuery header when useMessageBodyForSql=true
> -----------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25020
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25020
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-sql
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Minor
>             Fix For: 4.23.0
>
>
> Follow-up to CAMEL-24718.
> CAMEL-24718 made the observability call sites (the {{sql}} span decorator in camel-telemetry and the deprecated camel-tracing, plus {{SqlTraceDevConsole}}) consult the endpoint's {{allowQueryFromHeader}} option before reporting the {{CamelSqlQuery}} header, so the header is no longer attributed to an exchange that never executed it.
> That gate is incomplete. {{SqlProducer.process()}} short-circuits on {{useMessageBodyForSql}} *before* it ever looks at {{allowQueryFromHeader}}:
> {code:java}
> if (useMessageBodyForSql) {
>     sql = exchange.getIn().getBody(String.class);   // header never consulted
> } else {
>     String queryHeader = getEndpoint().isAllowQueryFromHeader()
>             ? exchange.getIn().getHeader(SqlConstants.SQL_QUERY, String.class) : null;
>     ...
> }
> {code}
> So for an endpoint configured with *both* {{allowQueryFromHeader=true}} and {{useMessageBodyForSql=true}}, the executed statement is the message body, but the shared {{isQueryHeaderHonoured()}} helper returns true and the span tag {{db.statement}} / the dev console both report the *header* instead. That is the same defect CAMEL-24718 fixed, in a narrower corner that was explicitly left out of scope at the time.
> Fix: treat {{useMessageBodyForSql=true}} as "header not honoured" in the three call sites, mirroring the producer's precedence.
> Note (out of scope here): when {{useMessageBodyForSql=true}} the console still falls back to the query parsed out of the endpoint URI, which is also not the statement that ran. That inaccuracy predates CAMEL-24718 and is not addressed by this issue.
> _Filed by Claude Code on behalf of Andrea Cosentino._



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