oscerd opened a new pull request, #25897:
URL: https://github.com/apache/camel/pull/25897

   ## Issue
   [CAMEL-24537](https://issues.apache.org/jira/browse/CAMEL-24537)
   
   ## Problem
   `OpenAIProducer` resolves the model and passes it straight to the SDK 
without a null check:
   
   ```java
   String model = resolveParameter(in, OpenAIConstants.MODEL, 
config.getModel(), String.class);
   ...
   ChatCompletionCreateParams.builder().model(model);   // model may be null
   ```
   
   When no `model` option is configured, no default is set and no 
`CamelOpenAIModel` header is supplied,
   `model` is null and the call fails deep inside the OpenAI SDK with an opaque 
`NullPointerException`.
   
   Every sibling producer already validates this — `OpenAIResponsesProducer`, 
the embeddings, moderation,
   audio and image-support producers. The chat-completion path was the only one 
missing the guard.
   
   ## Fix
   Add the same guard right after the model is resolved, throwing a clear 
`IllegalArgumentException`
   ("Model must be specified via model parameter or CamelOpenAIModel header"), 
matching the sibling
   producers.
   
   ## Testing
   - New `OpenAIChatCompletionMissingModelTest` sends an exchange to a 
chat-completion endpoint with no
     model configured and asserts the failure is an `IllegalArgumentException` 
with the clear message.
   - `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]

Reply via email to