fix: use Gemini API key query auth in doctor#25139
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes hermes doctor falsely flagging valid Google Gemini (Generative Language API) keys as invalid by switching the /models probe for generativelanguage.googleapis.com from Authorization: Bearer ... to the native ?key= query-parameter authentication.
Changes:
- Extracted a shared
/modelsprobe request builder to centralize URL/header construction. - Updated the probe logic to use
?key=(URL-encoded) and omit Bearer auth forgenerativelanguage.googleapis.com. - Added regression tests covering Gemini query-key auth, non-Gemini Bearer auth, and query-param preservation/encoding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
hermes_cli/doctor.py |
Introduces _build_models_probe_request and routes /models probes through it, using ?key= for generativelanguage.googleapis.com. |
tests/hermes_cli/test_doctor_gemini_auth.py |
Adds regression tests ensuring Gemini probing uses query-key auth and non-Gemini probing retains Bearer auth. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Addressed Copilot feedback in commit 7f24896. Changes:
|
|
Thanks for the duplicate-fix context. I kept this PR narrowly scoped to #25108 / Gemini doctor auth and added regression tests for the key behavior: Gemini uses URL-encoded ?key= auth, existing query params are preserved, and non-Gemini providers keep Bearer auth. If maintainers prefer one of #23364/#21490/#20642, happy for this to be superseded; otherwise this PR is ready as a focused implementation. |
|
Status update: This bug is fixed upstream in v0.14.0. The doctor now uses |
|
Closing as superseded by v0.14.0 which fixes Gemini doctor auth via x-goog-api-key header for generativelanguage.googleapis.com. |
Bug
hermes doctor probed Google Generative Language /models with Authorization: Bearer, which returns false 401 invalid-key results for valid Gemini API keys. Google native Gemini API keys are supplied via the key query parameter.
Fixes #25108
Summary
Extract the generic /models probe request builder and make generativelanguage.googleapis.com use ?key= with URL encoding and no Bearer header. Other OpenAI-compatible providers continue to use Authorization: Bearer.
TDD / ATDD coverage
Test plan
Review notes