## Issue Closes #4814 ## Change Added a null/empty guard for `getChoices()` in `AzureOpenAiChatModel.doChat()` before accessing `.get(0)`. **Before:** ```java ChatChoice chatChoice = chatCompletions.getChoices().get(0); ``` **After:** ```java if (isNullOrEmpty(chatCompletions.getChoices())) { throw new IllegalArgumentException("Chat completion failed: no choices returned"); } ChatChoice chatChoice = chatCompletions.getChoices().get(0); ``` This is consistent with the streaming counterpart `AzureOpenAiStreamingChatModel` which already has this guard (line 287-288). **Note:** No unit tests are added because the `OpenAIClient` is an Azure SDK class that requires a real or mock Azure endpoint. The existing tests in this module are integration tests (IT). The fix is a simple null/empty guard with clear correctness from code inspection. ## General checklist - [X] There are no breaking changes (API, behaviour) - [ ] I have added unit and/or integration tests for my change - [X] The tests cover both positive and negative cases - [X] I have manually run all the unit and integration tests in the module I have added/changed, and they are all green - [X] I have manually run all the unit and integration tests in the [core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core) and [main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j) modules, and they are all green - [ ] I have added/updated the [documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs) - [ ] I have added an example in the [examples repo](https://github.com/langchain4j/langchain4j-examples) (only for "big" features) - [ ] I have added/updated [Spring Boot starter(s)](https://github.com/langchain4j/langchain4j-spring) (if applicable) |
||
|---|---|---|
| .. | ||
| src | ||
| pom.xml | ||