oscerd opened a new pull request, #25939: URL: https://github.com/apache/camel/pull/25939
## Issue [CAMEL-24538](https://issues.apache.org/jira/browse/CAMEL-24538) ## Problem `OpenAIProducer.buildUserMessage` resolves the user prompt with: ```java if (userPrompt == null || userPrompt.isEmpty() && ObjectHelper.isNotEmpty(config.getUserMessage())) { userPrompt = config.getUserMessage(); } ``` `&&` binds tighter than `||`, so this parses as `userPrompt == null || (userPrompt.isEmpty() && configHasMessage)`. When the `CamelOpenAIUserMessage` header is absent (`userPrompt == null`) and the configured `userMessage` option is an **empty string**, the first branch is already true, so `userPrompt` is set to that empty string. `buildTextMessage` then does `userPrompt != null ? userPrompt : body`, picks the empty string over the message body, and the request fails with *"No input provided to LLM"* — the body prompt is silently dropped. ## Fix Parenthesise as `(userPrompt == null || userPrompt.isEmpty()) && ObjectHelper.isNotEmpty(config.getUserMessage())` so the configured message is only substituted when it is actually set; otherwise `userPrompt` stays null and the body is used. The identical precedence in the system-message branch is corrected too for consistency (that one was benign because its downstream check uses `isNotEmpty`). ## Testing - New `OpenAIEmptyUserMessageBodyPromptTest` configures the endpoint with an empty `userMessage` and asserts the body prompt still reaches the model. Verified it fails with *"No input provided"* against the unpatched code and passes with the fix. - `mvn -Psourcecheck validate` green. _Claude Code on behalf of oscerd_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
