fix: let app config override system env vars for API keys#439
Merged
gabrielste1n merged 1 commit intoOpenWhispr:mainfrom Mar 15, 2026
Merged
fix: let app config override system env vars for API keys#439gabrielste1n merged 1 commit intoOpenWhispr:mainfrom
gabrielste1n merged 1 commit intoOpenWhispr:mainfrom
Conversation
dotenv loaded the userData .env without override, so API keys exported in the user's shell profile always won. With override: true the keys saved through Settings take precedence.
gabrielste1n
approved these changes
Mar 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
API keys changed through Settings are ignored after app restart if the same key is exported in the user's shell environment
Problem
When a user changes an API key in Settings, it's saved to the app's
.envfile. Butdotenv.config()was called withoutoverride, so any matching environment variable (e.g.OPENAI_API_KEYin~/.profileor~/.bashrc) always took precedence after restart. The user sees the new key in the UI but the app uses the old one.Affects all API keys on any platform where the user exports keys in their shell.
Solution
Add
override: truetodotenv.config()for the userData.envfile only. Fallback.envfiles (development, resources, legacy) keep the default behavior so they don't override anything.Test plan
export OPENAI_API_KEY=old), set a different key in Settings, restart app, verify new key is used