fix: enable dotenv override for environment variables#120
Open
Sumit189 wants to merge 1 commit intohuggingface:mainfrom
Open
fix: enable dotenv override for environment variables#120Sumit189 wants to merge 1 commit intohuggingface:mainfrom
Sumit189 wants to merge 1 commit intohuggingface:mainfrom
Conversation
Co-authored-by: Copilot <copilot@github.com>
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.
Problem
When a user has a stale or invalid API key exported in their shell profile
(e.g.
export OPENAI_API_KEY=...in~/.zshrc), the project's.envfileis silently ignored because
load_dotenv()defaults tooverride=False.This makes the error message misleading, it suggests adding the key to
.env, but that doesn't actually fix anything when a shell export exists:Error: Authentication failed — your API key is missing or invalid. ... You can also add it to a .env file in the project root.The user ends up stuck: the key works with
curl, the.envlooks correct,but
ml-internkeeps rejecting it with no indication that a shell variableis shadowing the
.envvalue.Fix
Pass
override=Trueto the project-rootload_dotenv()call so the.envfile is the source of truth for API keys, matching the behavior the error
message already promises.