Andrea Cosentino created CAMEL-24538:
----------------------------------------

             Summary: camel-openai: operator-precedence bug can discard the 
prompt supplied in the message body
                 Key: CAMEL-24538
                 URL: https://issues.apache.org/jira/browse/CAMEL-24538
             Project: Camel
          Issue Type: Bug
          Components: camel-openai
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino
             Fix For: 4.23.0


OpenAIProducer (around line 306) computes the user prompt with:

    if (userPrompt == null || userPrompt.isEmpty() && 
ObjectHelper.isNotEmpty(config.getUserMessage()))

Because && binds tighter than ||, this parses as userPrompt==null || 
(userPrompt.isEmpty() && userMessage-not-empty). The intent was 
((userPrompt==null || userPrompt.isEmpty()) && userMessage-not-empty). With the 
current grouping, when the userMessage header is absent but the configured 
userMessage option is set to an empty string, userPrompt is left as "" and the 
prompt provided in the message body (applied later, around line 320) is never 
used, so the call ends up with "No input provided".

The correct grouping is used in OpenAIResponsesInputBuilder (line 49). The twin 
expression for the system message (line 249) is benign but should be 
parenthesised for consistency. Fix: add explicit parentheses.

_Claude Code on behalf of oscerd_



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

Reply via email to