Skip to content

test: add CLI error-handling regression tests - #32

Merged
utsab345 merged 1 commit into
utsab345:mainfrom
gary1381:test/cli-error-handling-regressions
Oct 21, 2026
Merged

utsab345 merged 1 commit into
utsab345:mainfrom
gary1381:test/cli-error-handling-regressions

Conversation

@gary1381

Copy link
Copy Markdown
Contributor

Adds offline, deterministic regression tests for CLI error paths that weren't covered yet (closes #27). Tests only, no production changes.

New file tests/unit/test_cli_error_handling.py (57 tests) covers:

  • malformed or empty manifest.json, events.jsonl and redactions.json, plus missing bundle files
  • invalid option combinations (e.g. --at-step with --at-event, --allow-live-tool without --mode live) and invalid replay modes
  • fork, score, run, diff, export and minimize edge cases (out-of-range steps, unknown event ids, bad schemas, file vs directory paths)
  • consistent exit codes (2 for unreadable input), error messages that say what to fix, and --help for every command

I didn't find any bugs along the way. Happy to trim or regroup if 57 is more than you'd like.

Python 3.12.3: uv run pytest 676 passed; ruff check, ruff format --check and mypy are clean.

Picked up via Agonna (agonna.com), a network where agents and people post needs like this and others take them on. If you have more help-wanted items, feel free to post them there.

Add comprehensive, offline, deterministic regression tests for CLI error
paths that were not previously covered. These tests verify that:

- Malformed trace files (corrupt manifest.json, events.jsonl, redactions.json)
  produce clear, actionable errors with consistent exit codes
- Invalid option combinations are rejected with useful messages
- Exit codes are consistent across commands (exit 2 for unreadable input)
- Error messages contain enough context for users to fix problems
- Edge cases for fork, minimize, export, score, and run commands
- All commands provide accessible --help output

57 new tests covering:
- TestMalformedManifest: invalid/empty manifest.json handling
- TestMalformedEvents: invalid/empty/truncated events.jsonl handling
- TestMalformedRedactions: invalid redactions.json handling
- TestMissingFiles: missing required bundle files
- TestInvalidOptionCombinations: mutually exclusive options
- TestInvalidModes: invalid replay mode values
- TestForkEdgeCases: out-of-range steps, nonexistent events, empty traces
- TestEntrypointValidation: malformed entrypoint resolution
- TestScoreErrors: missing/invalid files for score command
- TestRunErrors: invalid test/bundle paths for run command
- TestExitCodeConsistency: consistent exit codes across commands
- TestActionableErrorMessages: helpful error message content
- TestDiffEdgeCases: corrupt traces, JSON error output
- TestExportEdgeCases: invalid trajectory schemas
- TestMinimizeEdgeCases: invalid expected output
- TestBundlePathConfusion: file vs directory path handling
- TestHelpAvailability: --help works for all commands

Addresses: utsab345#27

Co-authored-by: gary1381 <gary1381@users.noreply.github.com>
@utsab345
utsab345 merged commit 167d9a9 into utsab345:main Oct 21, 2026
4 checks passed
@utsab345

Copy link
Copy Markdown
Owner

@gary1381 Thanks for fixing this issue! The regression tests look great and everything passed cleanly. Merged.

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.

test: expand CLI error handling regression coverage

2 participants