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

Work on CAMEL-25020 started by Andrea Cosentino.
------------------------------------------------
> 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
>
> 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)

Reply via email to