Skip to content

fix(ci): fail-to-pass prints a traceback when the base run times out #4938

Closed

Description

@dan-petty

Problem Description

devops ci fail-to-pass --base origin/main stops with a raw Python traceback when the pytest run on the base passes the limit of the process runner. _run_pytest_on_base (src/devops_cli/ci/fail_to_pass.py) calls run_subprocess(argv, cwd=tree_dir, capture_output=True) with the default limit of 1,800 s and does not catch subprocess.TimeoutExpired. The run of the base is also serial (-o addopts= removes -n logical), so 4 test modules of the implement job pass the limit on a busy host.

Reproduction Steps

  1. On a host with a load of about 50, change tests in tests/roadmap/implement/test_roadmap_implement_job.py, tests/roadmap/implement/test_roadmap_implement_push_current.py, tests/core/test_roadmap_implement_checks.py and add one test module.
  2. Run uv run devops ci fail-to-pass --base origin/main.

Expected vs Actual Behavior

Expected: a run of the base that passes its limit is a run that could not run. The command names the limit and the test files, and exits with its documented status, as for an interrupted pytest (#1669).

Actual: after 30 min 55 s the command prints a rich traceback that ends in TimeoutExpired: Command '[... '-m', 'pytest', '-o', 'addopts=', ...]' timed out after 1800.0 seconds.

Environment Diagnostics

devops-cli at origin/main cbdce63f (2026-11-12), Python 3.14.10, devcontainer, load average about 50.

Logs, Traces, or Terminal Output

TimeoutExpired: Command
'['<worktree>/.venv/bin/python', '-m', 'pytest', '-o', 'addopts=', '-p', 'no:cacheprovider',
'--continue-on-collection-errors', '--junitxml=/tmp/<tmp>/junit.xml',
'tests/core/test_roadmap_implement_checks.py', 'tests/git/test_branch_current_hook.py',
'tests/roadmap/implement/test_roadmap_implement_job.py',
'tests/roadmap/implement/test_roadmap_implement_push_current.py']' timed out after 1800.0 seconds
Elapsed: 30m 55s

Seen in the work on #4670 (PR #4879). Related: #4472 (a narrowed test run is serial).

Alternatives check of 2026-11-15: none.
Tool: none found.

Proposed design

Problem statement

The fail-to-pass command prints a raw Python traceback when the base pytest run exceeds the process-runner limit. The base run is serial, so a busy host can exceed 1,800 seconds. The command must catch the timeout, name the limit and the test files, and exit with its documented could-not-run status.

Acceptance criteria

Requirement: Base replay timeout is a could-not-run result

The fail-to-pass command SHALL treat a pytest replay that raises subprocess.TimeoutExpired as a replay that could not run.

Scenario: Base pytest timeout

  • WHEN The base pytest replay raises subprocess.TimeoutExpired.
  • THEN The command records a ReplayCouldNotRun result and prints no Python traceback.

Requirement: Timeout report names the limit and test files

The timeout report SHALL name the process-runner limit and each test file of the replay.

Scenario: Timeout report content

  • WHEN A pytest replay times out after 1,800 seconds.
  • THEN The report contains the 1,800 second limit and each test file path passed to pytest.

Requirement: Timeout uses the documented failure status

The command MUST exit with the same non-zero status that it uses for an interrupted pytest when a replay times out.

Scenario: Timeout exit status

  • WHEN A pytest replay times out.
  • THEN The command exits with the documented could-not-run status and not with an uncaught exception.

Requirement: Timeout does not report a false pytest status

The timeout result SHALL NOT report a pytest exit status that pytest did not return.

Scenario: Timeout message

  • WHEN The command reports a timed-out replay.
  • THEN The report names the timeout limit and does not print a pytest exit status line.

Requirement: Timeout handling covers each pytest replay

Each pytest replay in the fail-to-pass command SHALL use the same timeout handling.

Scenario: Head replay timeout

  • WHEN The head replay or the plain-base replay raises subprocess.TimeoutExpired.
  • THEN The command reports that replay as a replay that could not run and prints no traceback.

Existing Tool Considered

The alternatives check found no tool that covers the need. pytest-timeout (MIT, 2.4.0) only enforces a per-test timeout inside a pytest run. It does not catch the devops-cli run_subprocess timeout, name the 1,800 second limit and test files, or set the command's documented exit status. The in-repo change costs about 1,500 tokens to build, about 300 tokens to keep and fix, and about 1 hour elapsed.

Key questions

  • Which call raises the timeout that the command does not catch?: The call to run_subprocess in _run_pytest_replay raises subprocess.TimeoutExpired. That function runs the base, plain-base and head pytest replays. [sources: src/devops_cli/ci/fail_to_pass.py]
  • Where should the command catch the timeout?: Catch subprocess.TimeoutExpired in _run_pytest_replay and return a BaseReplayRun with could_not_run set. The existing report path then prints the could-not-run lines. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py]
    • Chosen: Catch in _run_pytest_replay. It covers each pytest replay with one change and uses the existing could-not-run report.
    • Rejected: Catch only in replay_on_base. It leaves the head and plain-base replays uncaught.
    • Rejected: Let TimeoutExpired propagate. It prints the raw traceback that the issue reports.
  • How should the timeout result carry the limit?: Add a timeout_seconds field to ReplayCouldNotRun and a new message. The report then names the limit without a false pytest exit status. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py, src/devops_cli/config/constants.py]
    • Chosen: Add timeout_seconds to ReplayCouldNotRun. It keeps the limit with the result and separates timeout from a pytest exit status.
    • Rejected: Reuse exit_status 124. It prints a pytest exit status that pytest did not return.
    • Rejected: Put the message in output_tail. It mixes a structured reason with raw output.
  • Which exit status should a timed-out replay use?: Use the existing documented non-zero status that an interrupted pytest uses. Do not add a new status. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py, src/devops_cli/config/constants.py]
  • Should the timeout limit be configurable?: No. Use the 1,800 second process-runner limit and pass it explicitly to run_subprocess so the report can name it. (best practice) [sources: src/devops_cli/core/process.py, src/devops_cli/config/constants.py]
    • Chosen: Use the existing 1,800 second limit. The issue asks to name the existing limit and no caller asks for another value.
    • Rejected: Add a CLI option. It expands the command surface with no requirement.
    • Rejected: Read an environment variable. It hides the limit from the report and adds configuration.
  • Should the change make the base run parallel?: No. The issue asks for timeout handling. The serial base run is separate work. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py]
    • Chosen: Handle the timeout. It matches the issue's expected behavior.
    • Rejected: Add xdist to the base run. It changes the test run and does not fix the traceback.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/ci
    status/new
    value/medium
    effort/low
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/ci. The (ci) scope of the title gives the scope.
    • Priority: P2-Medium. The command crashes with an unhandled traceback instead of a clean error, but the timeout itself still occurs; it is a usability defect, not a data-loss or security issue.
    • Value: Medium. Users see a 30-minute traceback instead of a one-line status, which is confusing but does not block the timeout from firing.
    • Effort: Low. Catch 'subprocess.TimeoutExpired' in one function and print the documented status message; the pattern already exists for interrupted pytest (#1669).
    • Related: fix(test): test run names its timeout, no traceback #4926, which asks for a different change. Both fix an unhandled 'TimeoutExpired' traceback in a devops-cli command, but in different commands ('ci fail-to-pass' vs 'test run') and different source files.
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Priority: P2-Medium. The bug gives a bad error message in an internal command and does not corrupt data or block a release.
    • Value: Medium. A clear timeout message and exit status help developers understand and retry a failed base run.
    • Effort: Low. The fix catches 'subprocess.TimeoutExpired' in one function and prints the limit and the test files.
    • Related: fix(test): test run names its timeout, no traceback #4926, which asks for a different change. Both stop a raw traceback when pytest passes the subprocess limit, but they change different commands and different handler code.
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches found no tool that covers the need: the only relevant hit, the pytest-timeout plugin (MIT, 2.4.0), only enforces a per-test timeout inside a pytest run, while the issue asks devops-cli itself to catch subprocess.TimeoutExpired from run_subprocess, name the 1,800 s limit and the test files, and exit with its documented status. That is a small in-repo error-handling change to _run_pytest_on_base, which no library provides.

    Tool: none found

    Lacks:

    Tools considered:

    Searches run:

    • python library handle subprocess.TimeoutExpired clean error message CLI, results: 5
    • pytest-timeout plugin limit per test run report which tests timed out, results: 5
    • pytest-timeout github repository pytest plugin, results: 5
    • timeout plugin for pytest on PyPI, results: 5

    Sources:

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  6. added
    status/ready
    and removed
    status/new
    on Nov 16, 2026
  7. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at fccb781 (see proposed design in issue body).

  8. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 17, 2026
  9. removed
    status/in-review
    on Nov 17, 2026
  10. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-18 01:44 UTC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/cisource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions