fix: prevent GIGACHAT_* env vars from overriding explicit connector settings#83
Open
temrjan wants to merge 1 commit into
Open
fix: prevent GIGACHAT_* env vars from overriding explicit connector settings#83temrjan wants to merge 1 commit into
temrjan wants to merge 1 commit into
Conversation
…ettings When GIGA_AGENT_GIGACHAT_FROM_ENV=true and GIGACHAT_CREDENTIALS is set in the environment, the GigaChat SDK (pydantic BaseSettings) picks up env vars even when explicit credentials are provided via connector settings. This breaks login/password (dev) and certificate auth when the user intends to use a different auth method than what env vars configure. Fix: suppress GIGACHAT_* env vars when creating GigaChat client in non-env mode, so only explicitly provided settings are used. Closes ai-forever#78 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Hi, just a gentle reminder about this PR. Would appreciate a review when you have a moment, thanks! |
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
Fixes #78 — when
GIGA_AGENT_GIGACHAT_FROM_ENV=trueandGIGACHAT_CREDENTIALSis set in the environment, the GigaChat SDK (pydantic BaseSettings) picks up env vars even when explicit credentials are provided via connector settings. This breaks login/password (dev) and certificate auth.Root cause: GigaChat SDK's
Settings(BaseSettings)readsGIGACHAT_*env vars for any field not explicitly passed. The SDK constructor filters outNonevalues before creatingSettings, so passingcredentials=Nonedoes not override the env var.Fix: Temporarily suppress
GIGACHAT_*env vars when creatingGigaChatclient in non-env mode via a context manager, so only explicitly provided settings are used.Changes
gigachat.py: Add_suppress_gigachat_env()context manager, wrapGigaChat()calls inget_api_object()andcheck_connection()for non-env modetest_registry.py: Add 2 tests — explicit dev and prod settings must not be overridden by env varsNotes
The issue also mentions certificate auth (
cert_file). The current connector doesn't expose a certificate auth type — happy to add it in a follow-up if needed.