fix(config): avoid recursion when loading a custom config - #189
Merged
Conversation
Resolving the data path during logger setup re-enters Config.get_config() while the singleton is still being constructed, causing infinite recursion. Remove logging from _Config.__init__ and add a regression test exercising the full Config.get_config() path with a custom config.
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
Loading a custom config file through
Config.get_config()(for exampleMXOPS_CONFIG=deployment/mxops_config.ini mxops data get -n devnet --path) crashed withRecursionError: maximum recursion depth exceeded.The data path is resolved while the
_Configsingleton is still being constructed, and that resolution callsConfig.get_config()again. Because the singleton instance is not assigned until the constructor returns, the re-entrant call builds another_Config, which resolves the data path again — looping indefinitely. Any config resolution performed during_Config.__init__re-enters the half-built singleton.Changes
_Config.__init__no longer resolves the data path (or any other configuration) while constructing the config, removing the re-entrant call.Testing
Config.get_config()singleton path with a custom config set viaMXOPS_CONFIG, asserting it resolves without recursing.MXOPS_CONFIG=<custom>.ini mxops data get -n devnet --pathnow resolves the custom data path successfully.