Repository navigation
Overhauled config implementation - #636
Conversation
tracyboehrer (tracyboehrer)
left a comment
There was a problem hiding this comment.
Copilot reproduced both issues below against the unchanged PR head, e26101ea05294c80e4bb05be525f2e91f52f713e. The earlier review threads are resolved, but these behaviors remain reproducible.
Medium: Default resolution mutates nested caller-owned settings
Location: libraries/microsoft-agents-activity/microsoft_agents/activity/config/_utils.py:317.
The shallow list copy retains references to nested containers. During configuration construction, _convert_lists(resolved) then normalizes those shared containers in place, changing the caller's primary settings or defaults before construction returns.
from microsoft_agents.activity.config import Configuration
source = {"Entries": [{"Scopes": {"0": "read"}}]}
Configuration.from_mapping(source, Unrelated=True)
assert source["Entries"][0]["Scopes"] == {"0": "read"}The assertion fails: source["Entries"][0]["Scopes"] has become ["read"]. Starting with a fresh source, Configuration.from_mapping({"Unrelated": True}, **source) also mutates the caller-owned defaults.
This is not only the documented sharing of nested values after shallow construction: binding itself changes the input. Copy the nested containers that normalization traverses, including containers inside lists, before converting them.
Medium: Logging validation rejects read-only mappings
Configuration binding accepts Mapping inputs and preserves nested mappings, but this validation requires a concrete dict. A read-only log-level mapping therefore raises ValueError during configuration loading, although the previous logging implementation could iterate it.
from types import MappingProxyType
from microsoft_agents.activity.config import load_configuration_from_env
load_configuration_from_env({
"LOGGING__LOGLEVEL": MappingProxyType({"default": "DEBUG"})
})Expected: configure the default logger at DEBUG. Actual: ValueError. The same rejection occurs through _LoggingConfiguration.from_mapping({"LOGLEVEL": ...}).
Validate against Mapping rather than dict, retaining rejection of non-mapping values.

Summary
Introduces a reusable, dictionary-backed
ConfigurationAPI inmicrosoft_agents.activity.config, with shared lookup, conversion, binding, and logging infrastructure. The existingload_configuration_from_env()return contract is retained.Changes
::-separated paths, ordered alternative keys,path()/xpath()helpers, nested sections, and matched source paths in diagnostics.__environment-variable separators, and indexed-mapping conversion to lists.LOGLEVEL,LOG_LEVEL, andlog_levelaliases.function.Compatibility and scope
Configurationis adictsubclass. Construction is shallow, so nested mutable values can remain shared.AGENTAPPLICATION,CONNECTIONS, andCONNECTIONSMAP; this PR does not migrate existing SDK consumers to the new API.ChannelId.includes()test cases without changing theChannelIdimplementation.Validation
e26101eon Python 3.12.10: 241 passed.Description prepared by Copilot from the PR changes and observed validation results.