Skip to content

Fixes for OutputExecutor banner detection issues - fixes #1115 - #1116

Open
fizyk wants to merge 1 commit into
mainfrom
issue-1115
Open

Fixes for OutputExecutor banner detection issues - fixes #1115#1116
fizyk wants to merge 1 commit into
mainfrom
issue-1115

Conversation

@fizyk

@fizyk fizyk commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Improved process output handling when large volumes of output are produced before the startup banner.
    • Banners split across multiple reads are now detected reliably.
    • Output waiting now respects configured timeouts and avoids hanging when a process exits before displaying its banner.
    • Output streams are drained more efficiently while preventing excessive waiting or spinning.
  • Tests

    • Added coverage for split-banner detection and timeout behaviour when processes exit prematurely.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

OutputExecutor now detects banners split across reads, drains sustained process output with bounded waits, and honours timeouts when output closes or the banner is absent.

Changes

OutputExecutor output handling

Layer / File(s) Summary
Banner consumption across reads
mirakuru/output.py, tests/executors/test_output_executor.py
OutputExecutor retains incomplete line tails, detects banners across reads, limits carried data, and consumes through the banner newline. Tests cover split-banner detection.
Output draining and timeout handling
mirakuru/output.py, tests/executors/test_output_executor.py, newsfragments/*
Darwin and poll-based waiters drain output with bounded waits and check executor timeouts during sustained output. Tests cover processes that exit before completing the banner. Bug-fix fragments document the corrected behaviours.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OutputExecutor
  participant OutputWaiter
  participant ReadableDescriptor
  OutputExecutor->>OutputWaiter: wait for banner output
  OutputWaiter->>ReadableDescriptor: drain available output
  ReadableDescriptor-->>OutputWaiter: output or closed stream
  OutputWaiter->>OutputExecutor: return on banner, quiet stream, or timeout
Loading

Possibly related issues

  • dbfixtures/mirakuru#1115 — The changes address the issue's banner consumption, output draining, and timeout handling defects.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarises the main changes to OutputExecutor banner detection and references the related issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Newsfragment Check ✅ Passed Three newsfragments were added under newsfragments/; each uses the configured valid bugfix type for this OutputExecutor fix.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-1115

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

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/executors/test_output_executor.py`:
- Around line 59-73: Update test_executor_dont_start_when_process_exits so its
elapsed-time assertion is bounded by the configured timeout value of 2 seconds
plus a small scheduling allowance, rather than a fixed ten-second limit. Keep
the TimeoutExpired expectation and executor.running() assertion unchanged.
🪄 Autofix

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: CHILL

Plan: Pro Plus

Run ID: 2a562d94-fd90-4f69-bd44-768d882fad0b

📥 Commits

Reviewing files that changed from the base of the PR and between 1cba210 and 5687e48.

📒 Files selected for processing (5)
  • mirakuru/output.py
  • newsfragments/1115.bugfix
  • newsfragments/1115.bugfix.1
  • newsfragments/1115.bugfix.2
  • tests/executors/test_output_executor.py

Comment on lines +59 to +73
def test_executor_dont_start_when_process_exits() -> None:
"""Executor should time out when the process ends without the banner.

Once the process is gone its output is at end of file, which descriptors
keep reporting as readable - that must not keep the executor spinning
instead of honouring its timeout.
"""
command = 'bash -c "echo foo"'
executor = OutputExecutor(command, "foobar", timeout=2)
start = time.time()
with pytest.raises(TimeoutExpired):
executor.start()

assert time.time() - start < 10
assert executor.running() is False

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Make the elapsed-time assertion enforce the configured timeout.

Line 72 accepts a delay of almost ten seconds when timeout=2. A regression that delays startup failure far beyond the configured timeout can pass this test. Assert against the timeout plus a small scheduling allowance.

🤖 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/executors/test_output_executor.py` around lines 59 - 73, Update
test_executor_dont_start_when_process_exits so its elapsed-time assertion is
bounded by the configured timeout value of 2 seconds plus a small scheduling
allowance, rather than a fixed ten-second limit. Keep the TimeoutExpired
expectation and executor.running() assertion unchanged.

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mirakuru/output.py 94.73% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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