fix: load_dotenv(override=True) so .env overrides stale OS env vars - #491
Open
Shtirmann wants to merge 1 commit into
Open
fix: load_dotenv(override=True) so .env overrides stale OS env vars#491Shtirmann wants to merge 1 commit into
Shtirmann wants to merge 1 commit into
Conversation
andreygetmanov
requested review from
DRMPN,
fl1pcoin and
korhenon
and removed request for
DRMPN and
fl1pcoin
August 28, 2026 09:52
andreygetmanov
approved these changes
Sep 4, 2026
| author: The name of the author of the pull request. | ||
| """ | ||
| load_dotenv() | ||
| # override=True so values from .env take precedence over a stale variable |
Collaborator
There was a problem hiding this comment.
Этот комментарий можно убрать
| from osa_tool.utils.utils import get_base_repo_url | ||
|
|
||
| load_dotenv() | ||
| # override=True so .env takes precedence over a stale OS-environment variable |
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.
load_dotenv()по умолчанию идёт сoverride=False, то есть переменная, уже сидящая в окружении ОС, побеждает значение из.env. Из-за этого устаревший ключ в среде (например, старыйOPENAI_API_KEY) затеняет свежий ключ из.env, и запросы к модели падают с невнятным401 "User not found"при том, что в.envвсё правильно.Отлаживается это неприятно: код и
.envвыглядят корректно, а ошибка приходит с сервера.Добавил
override=Trueво все места, где грузится.env.Теперь
.env- источник истины: обновил ключ в.env, и он реально применяется, даже если в окружении болтается старый..envтеперь имеет приоритет над OS-env. В CI без.envничего не меняется; локально.envстановится авторитетным.