Skip to content

fix: Group error log formatting - #4256

Merged
johanneskoester merged 5 commits into
snakemake:mainfrom
jlumpe:fix-group-error-formatting
Jul 29, 2026
Merged

johanneskoester merged 5 commits into
snakemake:mainfrom
jlumpe:fix-group-error-formatting

Conversation

@jlumpe

@jlumpe jlumpe commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Partial fix for #4248. It looks like this bug was introduced in #3107. In Job.get_log_error_info() the "name" key in the returned dict was changed to "rule_name". However DefaultFormatter._format_group_error() still used the "name" key when displaying error information for the jobs in the group. I'm not entirely sure why the error has gone mostly unnoticed until now.

Added a regression test which runs the existing test_group_job_fail test workflow and checks that the GROUP_INFO and GROUP_ERROR events were emitted and are present in formatted log output with no formatting errors.

Additional changes:

  • Gave the quiet argument to DefaultFormatter's constructor a default value of None.

I've also made some of the logging tests more robust in general to catch these sort of things:

  • test_log_events, test_log_events_dryrun, and test_rule_failure are existing tests that check that a certain set of job events are emitted:
    • Check for the presence of formatting errors in log output.
    • Check log output for presence of specific strings for all event types to ensure they are present.
  • Ensure the DEBUG_DAG event is emitted and checked in test_log_events. Required adding a debug_dag argument to the run() helper command which sets the corresponding property in OutputSettings.

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).
  • I, as a human being, have checked each line of code in this pull request

AI-assistance disclosure

I used AI assistance for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Summary by CodeRabbit

  • Bug Fixes
    • Improved error logging for grouped jobs so rule names are displayed correctly.
    • Prevented logging failures caused by incomplete error details from obscuring the original issue.
    • Improved reliability and consistency of workflow error messages, progress output, and job statistics.
  • Improvements
    • Logging configuration now works with the default quietness setting when no value is provided.

@jlumpe
jlumpe requested a review from johanneskoester as a code owner July 23, 2026 23:27
@jlumpe

jlumpe commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@cademirch

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Logging now handles grouped-job rule names correctly, permits omitted formatter quietness settings, wires DAG debugging into test runs, and expands logging regression coverage for formatter errors, stderr output, event counts, and grouped failures.

Changes

Logging validation

Layer / File(s) Summary
Formatter defaults and grouped error labels
src/snakemake/logging.py
DefaultFormatter defaults quiet to None, and grouped error formatting reads rule_name metadata.
Test runner debug output wiring
tests/common.py
The run helper accepts debug_dag and forwards it to OutputSettings.
Logging assertions and regression coverage
tests/test_logging.py
Tests detect formatter failures, support partial event-count checks and regex output matching, and cover debug DAG, rule failure, and grouped-job failure logging.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: johanneskoester

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR fixes the KeyError and adds tests, but it does not show the grouped-job retry behavior required by #4248. Add or verify code and regression tests for grouped-job retries, differing runtimes, and preserving outputs from successful tasks.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes stay focused on logging, tests, and related helper updates; no unrelated scope is evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main change: fixing grouped-job error log formatting.
Description check ✅ Passed The description includes the required PR summary, QC checklist, and AI-assistance disclosure sections.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/test_logging.py (1)

443-448: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy lift

Add grouped-job retry coverage.

This invocation leaves retries at its 0 default, so it cannot verify failed-group resubmission or retention of successful task outputs. Add a scenario with retries > 0 and differing task runtimes. Based on PR objectives, grouped-job retry behavior and successful outputs must be covered.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_logging.py` around lines 443 - 448, Extend the grouped-job failure
scenario around the run invocation for test_group_job_fail to set retries
greater than zero and use tasks with differing runtimes. Assert that failed
groups are resubmitted and successful task outputs are retained, covering
grouped-job retry behavior rather than only the default no-retry path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/test_logging.py`:
- Around line 443-448: Extend the grouped-job failure scenario around the run
invocation for test_group_job_fail to set retries greater than zero and use
tasks with differing runtimes. Assert that failed groups are resubmitted and
successful task outputs are retained, covering grouped-job retry behavior rather
than only the default no-retry path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d0a14deb-fd45-49d0-b1a9-0fbcc35700c2

📥 Commits

Reviewing files that changed from the base of the PR and between 1a27746 and 6280953.

📒 Files selected for processing (3)
  • src/snakemake/logging.py
  • tests/common.py
  • tests/test_logging.py

@jlumpe jlumpe changed the title Fix group error formatting fix: Group error log formatting Jul 24, 2026

@cademirch cademirch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks @jlumpe!

@johanneskoester
johanneskoester merged commit bb6dcde into snakemake:main Jul 29, 2026
87 checks passed
johanneskoester pushed a commit that referenced this pull request Jul 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[9.24.0](v9.23.1...v9.24.0)
(2026-07-30)


### Features

* allow to combine cases with otherwise in branch function
([#4262](#4262))
([000ff52](000ff52))


### Bug Fixes

* avoid config hash crash for non-serializable values
([#4241](#4241))
([1a27746](1a27746))
* compilation error when final line contains an f-string
([#4234](#4234))
([9c5e7fe](9c5e7fe))
* Group error log formatting
([#4256](#4256))
([bb6dcde](bb6dcde))
* leak of benchmark monitor threads
([#4259](#4259))
([d37852e](d37852e))
* no benchmark warning when a process exits before it can be sampled
([#4260](#4260))
([6738359](6738359))
* persistence starttime unset/defaults
([#4251](#4251))
([56395c0](56395c0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

4 participants