atiaomar1978-hub commented on PR #24882:
URL: https://github.com/apache/camel/pull/24882#issuecomment-5010359222

   ## CAMEL-23961 — Summary
   
   **Issue:** [CAMEL-23961](https://issues.apache.org/jira/browse/CAMEL-23961) 
— Empty `choices` array causes raw `IndexOutOfBoundsException`  
   **Component:** `camel-openai`  
   **Branch:** `CAMEL-23961-empty-choices-response` (pushed)
   
   ---
   
   ### Problem
   When an OpenAI-compatible provider returned HTTP 200 with an empty `choices` 
array, `OpenAIProducer` failed with:
   
   ```
   IndexOutOfBoundsException: Index 0 out of bounds for length 0
   ```
   
   This was inconsistent with `setResponseHeaders()` and 
`OpenAIToolExecutionProducer`, which already guard against empty choices.
   
   ---
   
   ### Fix
   
   | Area | Change |
   |------|--------|
   | **New helper** | `requireFirstChoice(exchange, response)` |
   | **Behavior** | Throws `CamelExchangeException("OpenAI response contained 
no choices", exchange)` |
   | **Paths covered** | Non-streaming **simple** and **agentic** loops |
   
   ---
   
   ### Commits
   
   | Commit | Description |
   |--------|-------------|
   | `36fc75910d3` | Main fix + Jira reproducer test |
   | `8b62d8067ae` | AssertJ assertions (review feedback) |
   
   ---
   
   ### Files Changed
   
   | File | Change |
   |------|--------|
   | `OpenAIProducer.java` | Validate `choices` before `get(0)` |
   | `OpenAIEmptyChoicesResponseTest.java` | New test (AssertJ) |
   
   ---
   
   ### Tests
   
   | Test | Result |
   |------|--------|
   | `OpenAIEmptyChoicesResponseTest` | **PASSED** |
   
   **Build:** `BUILD SUCCESS`


-- 
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