Skip to content

fix(loggers): explicitly set propagate=True in LoggerConfig#3120

Draft
sfc-gh-turbaszek wants to merge 3 commits into
mainfrom
fix/SNOW-caplog-propagate-loggers
Draft

fix(loggers): explicitly set propagate=True in LoggerConfig#3120
sfc-gh-turbaszek wants to merge 3 commits into
mainfrom
fix/SNOW-caplog-propagate-loggers

Conversation

@sfc-gh-turbaszek

Copy link
Copy Markdown
Contributor

Summary

  • LoggerConfig was missing a propagate field, so logging.config.dictConfig never explicitly set snowflake.cli.propagate
  • Python's configure_logger only sets propagate when the key is present in the config dict — without it, any stale propagate=False state on snowflake.cli survives across dictConfig calls
  • In pytest-xdist workers with many tests, this caused log records from snowflake.cli._app.* loggers to stop at snowflake.cli's file handler instead of propagating to root where pytest's caplog handler lives
  • The symptom: integration tests asserting on caplog.messages captured only the single message logged before dictConfig ("Creating directory ...") and none of the plugin load/registration messages logged after it

Fix

One-line change: add propagate: bool = True to LoggerConfig. asdict() now includes "propagate": True in the dictConfig payload, so configure_logger explicitly resets snowflake.cli.propagate = True on every CLI invocation.

Test plan

  • All 13 unit tests in tests/test_logs.py pass
  • Full unit test suite: 7504 passed (2 pre-existing unrelated snapshot failures in test_help_messages.py due to version-check banner)
  • Integration tests: fixes 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

sfc-gh-turbaszek and others added 3 commits June 18, 2026 07:00
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant