Skip to content

fixed the generateContent() produces empty text output #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

akhileshdasari2004
Copy link

Code Changes Summary:
Robust Response Validation:

Added optional chaining (?.) to safely check nested properties in the API response, preventing runtime errors if the response is empty or malformed.

Retry Mechanism:

Introduced a retry mechanism to handle transient issues (e.g., network errors or empty responses). The function retries the API call up to 3 times (configurable) to increase reliability.

Error Handling and Logging:

Added detailed error logging for each failed attempt, including the attempt number, error message, and full response (if available), making debugging easier.

Early Exit on Success:

The function exits early if a valid response is received, avoiding unnecessary retries and improving efficiency.

Code Structure:

Consolidated logic into a single function (getCapitalOfFranceWithRetry) for better readability and maintainability.

Copy link

google-cla bot commented Mar 7, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Annhiluc Annhiluc added status:triaged Issue/PR triaged to the corresponding sub-team p2 labels Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 status:triaged Issue/PR triaged to the corresponding sub-team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants