Repository navigation
fix: ignore whitespace around the API key - #189
Conversation
A key read from a file or an environment variable often ends with a newline. httpx refused the resulting Authorization header with an error that printed it, key included. The key is now stripped where it is read, so such a key simply works.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the narrowly scoped API-key whitespace normalization change.
No open issues 🎉
What changed in this PR
This pull request trims surrounding whitespace from API keys read from arguments or FISH_API_KEY, allowing keys with trailing newlines to authenticate while preserving existing missing-key validation.
Changes:
- Strip leading and trailing whitespace from API keys before validation and authorization.
- Preserve the existing error for empty or whitespace-only keys.
- Add tests covering argument input, environment input, and whitespace-only keys.
| File | Description |
|---|---|
| tests/unit/test_core.py | Adds tests verifying whitespace normalization for argument- and environment-sourced API keys, including whitespace-only values. |
| src/fishaudio/core/client_wrapper.py | Trims surrounding whitespace from the API key before validation and request authentication. |
Review effort: Lite
What
The API key is stripped of surrounding whitespace where it is read (argument or
FISH_API_KEY).Why
A key read from a file or an environment variable often ends with a newline. httpx then refuses the
Authorizationheader with aLocalProtocolErrorwhose message prints the header, key included. With this change such a key simply works.A key that is empty after stripping raises the existing "API key must be provided" error. A key with whitespace in the middle is not touched and still fails as before.
Verification
poe checkpasses. Three new tests intests/unit/test_core.pycover a key from the argument, a key from the environment, and a whitespace-only key.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit