Skip to content

fix(runners, server): prevent CLI error traceback loss and missing failure details - #7

Open
AkshatSoni26 wants to merge 2 commits into
Maxed-OSS:mainfrom
AkshatSoni26:fix/hybrid-log-truncation
Open

fix(runners, server): prevent CLI error traceback loss and missing failure details#7
AkshatSoni26 wants to merge 2 commits into
Maxed-OSS:mainfrom
AkshatSoni26:fix/hybrid-log-truncation

Conversation

@AkshatSoni26

@AkshatSoni26 AkshatSoni26 commented Jul 23, 2026

Copy link
Copy Markdown

Problem & Motivation

  1. Loss of Error Tracebacks: In CLI subprocess executions, critical error details (Python tracebacks, assertion failures, exit summaries) almost always appear at the end of stderr/stdout. The previous head-slicing approach ([:2000]) drops the actual root-cause traceback whenever log output exceeds 2,000 characters.
  2. Loss of Failure Context: In runners.py, non-zero exit codes with stdout present were bypassing the command_failed error envelope, and in server.py, useful stdout execution hints were omitted from command failure details.

Solution & Changes

  • Hybrid Log Truncation (truncate_output):
    • Preserves initial command invocation context (first 1,000 chars).
    • Adds an explicit truncation marker (... [N chars truncated] ...).
    • Preserves trailing stack trace / error root cause (last 1,000 chars).
  • Consolidated Error Envelopes (run_json & _wrap_cli):
    • Non-zero exit status (code != 0) consistently returns command_failed.
    • Both stdout and stderr are safely truncated using truncate_output() and attached to error.detail.
  • Unit Tests:
    • Added test coverage in test_runners.py for truncate_output (empty strings, under-limit, over-limit, custom limits, long output).
    • Added test coverage in test_server.py verifying _wrap_cli preserves stdout details on command failure.

Prior Art & Credit

This PR builds on the motivation explored in open PR #5 and PR #6 by @abhinavgautam01 (preserving stdout on command failures), extending the pattern by centralizing log truncation into a reusable, tested helper function.

@AkshatSoni26 AkshatSoni26 changed the title fix(runners): use hybrid head/tail log truncation to preserve CLI error tracebacks fix(runners, server): prevent CLI error traceback loss and missing failure details Jul 23, 2026
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