[Bug]: --top integer parsing / validation bug
Summary
--top is not reliably validated as a positive integer and can behave incorrectly for invalid values (and an existing test may be masking the bug).
Expected Behavior
--toponly accepts a positive integer.- Invalid values (non-integers, 0, negatives) fail with a clear error message on stderr and a non-zero exit code.
Actual Behavior
--top accepts invalid input or fails in an unclear way (parsing/typing bug).
Steps to Reproduce
Try:
oracletrace your_script.py --top foooracletrace your_script.py --top 0oracletrace your_script.py --top -5
Proposed Solution
- Enforce
--topas a positive integer at argument parsing level - Print a friendly error to stderr and exit non-zero
- Fix/replace the test that currently masks the issue
Acceptance Criteria
- Invalid
--topvalues are rejected with stderr + non-zero exit - Valid values work and correctly limit output
- Tests cover valid/invalid cases
Affected Files
oracletrace/cli.pytests/test_cli.py
Hi, I'd like to work on this issue.
I've identified the root cause: on cli.py:91, int(args.top[0]) indexes into the string, so --top 10 becomes int("1") = 1 instead of 10. The fix is to use type=int in argparse and add a validation check for positive values, plus redirect error messages to stderr. I'll submit a PR shortly.
Hi @CrepuscularIRIS ! Very nice, I thought it was something like that. Feel free to work on this and let me know if you have any questions. Thanks!