Skip to content

fix: prevent infrastructure logs from flooding webhook JSONL files (#1035)#1037

Merged
myakove merged 2 commits intomainfrom
fix/issue-1035-mcp-logs-empty
Mar 17, 2026
Merged

fix: prevent infrastructure logs from flooding webhook JSONL files (#1035)#1037
myakove merged 2 commits intomainfrom
fix/issue-1035-mcp-logs-empty

Conversation

@myakove
Copy link
Copy Markdown
Collaborator

@myakove myakove commented Mar 17, 2026

Summary

  • Only attach JsonLogHandler to the main webhook logger, not infrastructure loggers (mcp_server, logs_server)
  • Filter infrastructure noise entries in log viewer streaming
  • Add tests for logging separation and noise filtering

Problem

Infrastructure loggers (MCP server, log viewer) were writing to webhooks_*.json via JsonLogHandler, flooding the file with context-less entries. When querying via MCP, these noise entries were the most recent (generated by the MCP call itself), drowning out actual webhook data and returning 0 useful results.

Changes

File Change
webhook_server/utils/helpers.py Only attach JsonLogHandler when no explicit log_file_name is provided
webhook_server/web/log_viewer.py Add _is_infrastructure_noise() filter for streaming, skip entries from infra loggers with no webhook context
webhook_server/tests/test_logging_separation.py NEW — 9 tests for handler attachment and noise filtering

Test plan

  • All 1425 tests pass, 90.37% coverage
  • Deploy and verify MCP queries return webhook data
  • Verify mcpl call github-webhook-logs-myakove get_log_entries '{"limit": 5}' returns entries

Closes #1035

Summary by CodeRabbit

Release Notes

  • New Features

    • Webhook log queries now automatically exclude infrastructure and system noise entries that are not associated with a specific webhook, providing cleaner and more focused results.
  • Tests

    • Added comprehensive test coverage for logging separation and infrastructure noise filtering functionality.

…1035)

Infrastructure loggers (mcp_server, logs_server) were writing to
webhooks_*.json via JsonLogHandler, drowning out webhook data.

- Only attach JsonLogHandler to the main webhook logger, not infra loggers
- Filter infrastructure noise entries in log viewer streaming
- Add tests for logging separation and noise filtering
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 17, 2026

Walkthrough

This PR implements infrastructure noise filtering for webhook log queries by modifying the JsonLogHandler attachment logic and introducing a new infrastructure noise detector in LogViewerController. It prevents infrastructure-only logs from polluting webhook-specific queries while preserving infrastructure logs with webhook context.

Changes

Cohort / File(s) Summary
Infrastructure Noise Filtering
webhook_server/web/log_viewer.py
Introduces _INFRASTRUCTURE_LOGGERS frozenset and _is_infrastructure_noise() static method to filter log entries without webhook context. Applies filtering across JSON and text log streaming paths to exclude infrastructure noise from queries and exports.
JsonLogHandler Attachment Logic
webhook_server/utils/helpers.py
Refines conditional for attaching JsonLogHandler: handler now attaches only when log_file_path_resolved exists AND log_file_name is NOT provided. Prevents handler attachment for infrastructure loggers and ensures single handler per logger instance.
Logging Separation Tests
webhook_server/tests/test_logging_separation.py
Adds comprehensive unit tests validating: explicit log_file_name handling to prevent JsonLogHandler attachment for infrastructure loggers, _is_infrastructure_noise behavior via LogViewerController for various logger patterns and hook_id values, and filesystem mocking via os.path.isdir and os.makedirs patching.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Reasoning: Three files modified with 150+ net new lines spanning test code, utility conditional logic, and controller filtering logic. The infrastructure noise detection pattern is relatively straightforward (check logger name against frozenset + verify hook_id is None), but requires understanding the logging separation strategy and verifying correct application across multiple streaming paths. Test additions are extensive and follow consistent patterns. Changes are focused on one feature domain but demand verification across heterogeneous code sections.

Possibly related PRs

Suggested labels

size/L, branch-main

Suggested reviewers

  • rnetser
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.37% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: preventing infrastructure logs from flooding webhook JSONL files, which directly addresses issue #1035.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from #1035: prevents infrastructure loggers from writing to webhook JSONL files via conditional JsonLogHandler attachment, adds noise filtering during streaming, and includes comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing issue #1035: modifications to handler attachment logic, addition of infrastructure noise detection, and corresponding test coverage are all necessary for the stated fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1035-mcp-logs-empty
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@myakove
Copy link
Copy Markdown
Collaborator Author

myakove commented Mar 17, 2026

/reprocess

@myakove-bot
Copy link
Copy Markdown
Collaborator

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: Disabled for this repository
  • Pre-commit Checks: pre-commit runs automatically if .pre-commit-config.yaml exists
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: All label categories are enabled (default configuration)

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest python-module-install - Test Python package installation
  • /retest pre-commit - Run pre-commit hooks and checks
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. LGTM Count: Minimum 1 /lgtm from reviewers
  3. Status Checks: All required status checks must pass
  4. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  5. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • myakove
  • rnetser

Reviewers:

  • myakove
  • rnetser
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@webhook_server/tests/test_logging_separation.py`:
- Around line 123-174: The test
test_json_handler_attached_when_log_file_name_default is non-deterministic
because it patches os.makedirs but not os.path.isdir, so on CI where
/tmp/data/logs already exists makedirs may not be invoked; update the test to
also patch os.path.isdir (e.g., patch("os.path.isdir", return_value=False))
inside the same with(...) block used for get_logger_with_params so the code path
that calls os.makedirs is forced consistently when exercising
get_logger_with_params and JsonLogHandler attachment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0c22e3d9-d3f6-4b71-b974-d3c6326039b4

📥 Commits

Reviewing files that changed from the base of the PR and between ffb4c8a and b66029c.

📒 Files selected for processing (3)
  • webhook_server/tests/test_logging_separation.py
  • webhook_server/utils/helpers.py
  • webhook_server/web/log_viewer.py

Comment thread webhook_server/tests/test_logging_separation.py
coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 17, 2026
@myakove myakove merged commit d07a720 into main Mar 17, 2026
6 of 8 checks passed
@myakove myakove deleted the fix/issue-1035-mcp-logs-empty branch March 17, 2026 16:14
@myakove-bot
Copy link
Copy Markdown
Collaborator

New container for ghcr.io/myk-org/github-webhook-server:latest published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: log viewer MCP server returns empty results after JSON logging changes

2 participants