oracletrace icon indicating copy to clipboard operation
oracletrace copied to clipboard

[Bug]: --repeat accepts invalid values and can crash or silently misbehave

Open KaykCaputo opened this issue 5 months ago • 0 comments

Summary

The --repeat flag has no input validation. Invalid values can raise an uncaught ValueError, while 0 or negative values are silently treated as a single run.

Expected Behavior

Invalid --repeat values should be rejected with a clear stderr message and exit code 1, consistent with --top validation via _validate_top().

Actual Behavior

  • --repeat abc → uncaught ValueError: invalid literal for int() with base 10: 'abc'
  • --repeat 0 or --repeat -1 → silently runs once (because runs > 1 is false), with no warning

Steps to Reproduce

  1. Run command:

  2. Use input/script:

  3. Observe output/error:

  4. Create a minimal script app.py with print("ok")

  5. Run oracletrace app.py --repeat abc

  6. Observe a Python traceback instead of a friendly CLI error

Repeat with --repeat 0 and --repeat -1 — both exit 0 after a single trace run.

Command and Output

oracletrace app.py --repeat abc
ValueError: invalid literal for int() with base 10: 'abc'
oracletrace app.py --repeat 0
# Runs once, exits 0 — no warning that repeat was ignored

Environment

  • OracleTrace version: 3.0.0
  • Python version: 3.11+
  • OS: any
  • Shell/terminal (if relevant): any

Additional Context

Relevant code in oracletrace/cli.py:

runs: int = int(args.repeat)

_validate_top() already provides the pattern to follow (lines 29–39). Add _validate_repeat() and call it in _run_target() before the repeat loop. Add tests in tests/test_cli.py mirroring the existing --top rejection tests.

Checklist

  • [x] I searched existing issues before opening this report
  • [x] I provided a reproducible example or clear reproduction steps
  • [x] I included version and environment details

KaykCaputo avatar Jun 16 '26 17:06 KaykCaputo