Description
When using the "Generate Image" feature in the Image block within the WordPress Block Editor, clicking the "Generate" button results in the following error:
Error message: Unexpected Google API response: Missing the "candidates[0].content" key.
Expected behavior: The image should be generated successfully based on the provided prompt and inserted into the Image block.
Actual behavior: The generation fails immediately and the error is displayed in a red banner below the "Generate" button in the "Generate Image" modal dialog. No image is generated.
Environment:
- WordPress: 7.0 Release Candidate
- AI Plugin: Installed via Beta Tester Plugin
- Testing Platform: WordPress Playground (https://playground.wordpress.net)
- AI Service Provider: Google (Gemini API)
This appears to be an issue with the Google API response handling. The API response is missing the expected candidates[0].content key, which suggests either the API response format has changed, the request is being rejected by the API without a proper candidates response, or there is a parsing issue in the plugin's Google API integration.
Step-by-step reproduction instructions
- Set up WordPress 7.0 Release Candidate on WordPress Playground (or local environment) with the AI plugin installed via the Beta Tester Plugin.
- Open the Block Editor (e.g., edit an existing post or create a new one).
- Add an Image block to the post.
- Click the "Generate Image" button in the Image block toolbar/placeholder.
- In the "Generate Image" modal dialog, enter a prompt (e.g., "Kickstart Your Blogging Journey: Welcome to Your First WordPress Post!").
- Click the "Generate" button.
- Observe the error:
Unexpected Google API response: Missing the "candidates[0].content" key. displayed in a red banner below the Generate button.
Screenshots, screen recording, code snippet
Screenshot of the error is attached below showing the "Generate Image" modal with the error message displayed in a red banner.
Error shown: Unexpected Google API response: Missing the "candidates[0].content" key.
Environment info
- WordPress version: 7.0 Release Candidate
- AI Plugin version: Installed via Beta Tester Plugin
- Active Theme: Default theme (Twenty Twenty-Five or similar)
- Browser: [Brave 1.88.138 (Official Build) (arm64)] Chromium: 146.0.7680.178
- Device: Desktop with macOS 15.7.5
- Testing Platform: WordPress Playground (https://playground.wordpress.net)
- AI Service Provider: Google (Gemini API)
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except the AI plugin.
Please confirm which theme type you used for testing.
Description
When using the "Generate Image" feature in the Image block within the WordPress Block Editor, clicking the "Generate" button results in the following error:
Error message:
Unexpected Google API response: Missing the "candidates[0].content" key.Expected behavior: The image should be generated successfully based on the provided prompt and inserted into the Image block.
Actual behavior: The generation fails immediately and the error is displayed in a red banner below the "Generate" button in the "Generate Image" modal dialog. No image is generated.
Environment:
This appears to be an issue with the Google API response handling. The API response is missing the expected
candidates[0].contentkey, which suggests either the API response format has changed, the request is being rejected by the API without a proper candidates response, or there is a parsing issue in the plugin's Google API integration.Step-by-step reproduction instructions
Unexpected Google API response: Missing the "candidates[0].content" key.displayed in a red banner below the Generate button.Screenshots, screen recording, code snippet
Screenshot of the error is attached below showing the "Generate Image" modal with the error message displayed in a red banner.
Error shown:
Unexpected Google API response: Missing the "candidates[0].content" key.Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except the AI plugin.
Please confirm which theme type you used for testing.