Warn when Config singleton is re-requested with different parameters#102
Merged
urajat merged 2 commits intoApr 7, 2026
Merged
Conversation
BaseConfig.__init__ now detects when an already-initialized singleton is called with different region, timeout, runtime_base_url, or management_base_url and logs a WARNING with the mismatched values. This surfaces a silent failure mode where callers unknowingly get back a Config with different settings than requested. The singleton behavior is preserved — this only adds visibility. Fixes: AIFW-21679 Made-with: Cursor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff1a61ea83
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Merge positional args into the comparison so Config("eu-central-1")
triggers the warning just like Config(region="eu-central-1")
- Normalize URLs by stripping trailing slashes before comparison to
avoid false-positive warnings when the same effective URL is passed
Adds regression tests for both cases.
Made-with: Cursor
psg-cisco
approved these changes
Apr 7, 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
BaseConfig.__init__now detects when an already-initialized singleton is called with differentregion,timeout,runtime_base_url, ormanagement_base_urland logs aWARNINGwith the mismatched values"us"→"us-west-2") are normalized before comparison so equivalent regions don't trigger false warningsConfig()is called with no kwargs (common default usage)Context
Fixes AIFW-21679. When middleware (e.g., LangChain) creates multiple SDK clients with different
Config(region=..., timeout=...)calls, the second call silently returns the first instance with the original parameters. Users get incorrect behavior with no indication.Test plan
test_config_warns_on_different_region— different region triggers warningtest_config_warns_on_different_timeout— different timeout triggers warningtest_config_no_warning_on_same_params— identical params produce no warningtest_config_no_warning_on_short_region_alias—"us"vs"us-west-2"correctly recognized as equivalenttest_config_no_warning_when_no_kwargs— bareConfig()call produces no warningtest_config.pytests continue to passMade with Cursor