Skip to content

Fix #142: treat blank API keys in .env as unset#154

Open
evcyen wants to merge 1 commit into
safety-research:mainfrom
evcyen:fix/142-blank-api-keys-as-unset
Open

Fix #142: treat blank API keys in .env as unset#154
evcyen wants to merge 1 commit into
safety-research:mainfrom
evcyen:fix/142-blank-api-keys-as-unset

Conversation

@evcyen

@evcyen evcyen commented Feb 24, 2026

Copy link
Copy Markdown

Fixes #142

When a key is present in .env but empty, dotenv sets it to "", so downstream code gets a non-None value and providers raise AuthenticationError. This change removes any env var whose name ends in _API_KEY (or is HF_TOKEN) when its value is blank or whitespace-only, so “unset” is consistent and new *_API_KEY vars get the same behavior without code changes. Adds tests for blank, whitespace-only, and generic *_API_KEY normalization.

@evcyen evcyen force-pushed the fix/142-blank-api-keys-as-unset branch from c2e62df to fa9a7f8 Compare February 24, 2026 02:17
- Normalize any env var ending in _API_KEY (or HF_TOKEN) when value is blank/whitespace
- Add tests for blank, whitespace-only, and generic *_API_KEY behavior
@evcyen evcyen force-pushed the fix/142-blank-api-keys-as-unset branch from fa9a7f8 to b72c70a Compare February 24, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minor bug: API keys left blank in .env are not considered 'None'

1 participant