Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jerop
Copy link
Contributor

@jerop jerop commented Aug 7, 2025

GitHub Actions defaults to passing an empty string for optional inputs that are not explicitly set in a workflow. When the gemini_api_key input is unset, it is passed as an empty string to the GEMINI_API_KEY environment variable.

The Gemini CLI does not handle an empty GEMINI_API_KEY variable gracefully, which can lead to unexpected behavior.

This commit addresses the issue by explicitly checking if the GEMINI_API_KEY variable is empty (-z). If it is, the variable is unset before invoking the Gemini CLI. This ensures the CLI's default authentication behavior (e.g., using Application Default Credentials) is triggered correctly when no API key is provided, improving the action's robustness and predictability.

Note: This is a temporary workaround to unblock users. The underlying issue of handling empty string inputs will be addressed with improved validation in the Gemini CLI upstream.

Fixes: #123

GitHub Actions defaults to passing an empty string for optional inputs that are not explicitly set in a workflow. When the `gemini_api_key` input is unset, it is passed as an empty string to the `GEMINI_API_KEY` environment variable.

The Gemini CLI does not handle an empty `GEMINI_API_KEY` variable gracefully, which can lead to unexpected behavior.

This commit addresses the issue by explicitly checking if the `GEMINI_API_KEY` variable is empty (`-z`). If it is, the variable is unset before invoking the Gemini CLI. This ensures the CLI's default authentication behavior (e.g., using Application Default Credentials) is triggered correctly when no API key is provided, improving the action's robustness and predictability.

Note: This is a temporary workaround to unblock users. The underlying issue of handling empty string inputs will be addressed with improved validation in the Gemini CLI upstream.
@jerop jerop marked this pull request as ready for review August 7, 2025 05:54
@jerop jerop requested review from a team as code owners August 7, 2025 05:54
@jerop jerop merged commit df6eba2 into main Aug 7, 2025
12 checks passed
@jerop jerop deleted the fix/empty-api-key branch August 7, 2025 06:01
google-github-actions-bot added a commit that referenced this pull request Aug 7, 2025
## What's Changed
* fix: typo in `gemini-pr-review.yml` by @JamBalaya56562 in
#124
* fix(action): Unset empty gemini_api_key environment variable by @jerop
in #127


**Full Changelog**:
v0.1.5...v0.1.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

401 error at Run Gemini PR Review step when using WIF authentication

3 participants