fix(loggers): explicitly set propagate=True in LoggerConfig#3120
Draft
sfc-gh-turbaszek wants to merge 3 commits into
Draft
fix(loggers): explicitly set propagate=True in LoggerConfig#3120sfc-gh-turbaszek wants to merge 3 commits into
sfc-gh-turbaszek wants to merge 3 commits into
Conversation
Python's dictConfig only sets logger.propagate when the key is present
in the config dict. Without an explicit value, any stale propagate=False
state on snowflake.cli survives across dictConfig calls, causing log
records from child loggers to stop at snowflake.cli's file handler
instead of propagating to root where pytest's caplog handler lives.
This manifested as flaky integration test failures in pytest-xdist
workers: tests asserting on caplog.messages captured only the one
message logged before dictConfig ("Creating directory ...") and
nothing after it (plugin load/registration messages).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
logging.config.dictConfig always calls _clearExistingHandlers() which zeroes logging.root.handlers, silently removing pytest's LogCaptureHandler (caplog) before plugin registration messages are logged. Capture any handlers on root that were not installed by a prior dictConfig call (identified by absence from logging._handlers) and restore them after dictConfig runs. In production root has no handlers, so this is a no-op. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
LoggerConfigwas missing apropagatefield, sologging.config.dictConfignever explicitly setsnowflake.cli.propagateconfigure_loggeronly setspropagatewhen the key is present in the config dict — without it, any stalepropagate=Falsestate onsnowflake.clisurvives across dictConfig callssnowflake.cli._app.*loggers to stop atsnowflake.cli's file handler instead of propagating to root where pytest'scaploghandler livescaplog.messagescaptured only the single message logged before dictConfig ("Creating directory ...") and none of the plugin load/registration messages logged after itFix
One-line change: add
propagate: bool = TruetoLoggerConfig.asdict()now includes"propagate": Truein the dictConfig payload, soconfigure_loggerexplicitly resetssnowflake.cli.propagate = Trueon every CLI invocation.Test plan
tests/test_logs.pypasstest_help_messages.pydue to version-check banner)test_broken_command_path_plugin,test_failing_plugin,test_override_build_in_commands,test_loading_of_installed_plugins_if_all_plugins_enabled,test_loading_of_installed_plugins_if_only_one_plugin_is_enabled,test_enabled_value_must_be_boolean[*]🤖 Generated with Claude Code