Skip to content

fix(logging): tag keboola-owned handlers; only remove those in set_default_logger#95

Merged
matyas-jirat-keboola merged 8 commits intomainfrom
fix/set-default-logger-handler-removal
Apr 9, 2026
Merged

fix(logging): tag keboola-owned handlers; only remove those in set_default_logger#95
matyas-jirat-keboola merged 8 commits intomainfrom
fix/set-default-logger-handler-removal

Conversation

@matyas-jirat-keboola
Copy link
Copy Markdown
Contributor

@matyas-jirat-keboola matyas-jirat-keboola commented Apr 1, 2026

Summary

  • set_default_logger and set_gelf_logger iterated root.handlers while calling removeHandler in the same loop body — a classic mutation-during-iteration bug that caused alternating handlers to be skipped.
  • More impactfully, all root handlers were removed indiscriminately, dropping any external handlers installed before the component initialised (e.g. LogCaptureHandler from keboola.vcr test infrastructure).

Fix: handlers created by keboola.component are tagged with _keboola_owned = True. Both methods now iterate list(root.handlers) (a copy) and only remove tagged handlers, leaving anything else untouched.

Test plan

  • Existing python-component unit tests pass
  • Verified against keboola.ex-oracle-hyperion functional test suite (20/20 tests pass) with keboola.vcr log-capture feature that relies on LogCaptureHandler surviving set_default_logger calls

🤖 Generated with Claude Code


Open with Devin

matyas-jirat-keboola and others added 4 commits March 5, 2026 21:25
TestPyPI publish now only runs on workflow_dispatch (manual).
On release it was failing the pipeline unnecessarily.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
keboola-vcr requires Python >=3.10; the old >=3.8 floor caused uv
dependency resolution to fail on 3.8/3.9 CI matrix legs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Minimum supported version is now 3.10 (keboola-vcr constraint).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fault_logger

set_default_logger and set_gelf_logger iterated root.handlers while calling
removeHandler in the same loop body, causing mutation-during-iteration skips
(alternating handlers were missed). More importantly, all handlers were removed
indiscriminately, dropping any test-infrastructure handlers (e.g. LogCaptureHandler
from keboola.vcr) that were installed before the component initialised.

Fix: mark handlers created by keboola.component with _keboola_owned = True and
only remove those. External handlers installed by test frameworks survive
set_default_logger calls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

The GELF handler added in set_gelf_logger was not tagged, so the
cleanup loop (which only removes _keboola_owned handlers) left it on
the root logger when set_default_logger or set_gelf_logger was called
again, causing duplicate log delivery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@soustruh soustruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks for your sideways explanation, LGTM ദ്ദി(•ᴗ•)

@matyas-jirat-keboola matyas-jirat-keboola merged commit 51eb18a into main Apr 9, 2026
2 checks passed
@matyas-jirat-keboola matyas-jirat-keboola deleted the fix/set-default-logger-handler-removal branch April 9, 2026 10:51
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.

2 participants