ValueError: The `GenerateContentResponse::parts()` quick accessor only works for a single candidate,but none were returned
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3588223. -->
Reported by: [stijnstroobants](https://www.drupal.org/user/1787140)
Related to !36
>>>
<p>When Gemini blocks a prompt, it returns zero candidates, and calling $response->parts() throws a ValueError.<br>
I think the fix is to guard against empty candidates in GeminiProvider.php.</p>
<p>Error:<br>
ValueError: The `GenerateContentResponse::parts()` quick accessor only works for a single candidate,but<br>
none were returned. Check the `GenerateContentResponse::$promptFeedback` to see if the prompt was blocked. in<br>
Gemini\Responses\GenerativeModel\GenerateContentResponse->parts() (regel 47 van<br>
/dev/vendor/google-gemini-php/client/src/Responses/GenerativeModel/GenerateContentResponse.php). </p>
issue