Repository navigation
bvh_match: refuse --json directory before scanning or writing - #6630
Conversation
|
Tested 034802c merged with main 103e464 on Linux/Python 3.12.16: pass Commands (clean merge,
Diff read: no concern. The directory check sits before the alias loop and before any input is opened, returns 2 with the path on stderr, and the test passes input paths that do not exist, so it also proves nothing is read first. |
|
Tested 034802c on Windows 11 (NTFS), Python 3.12.10 (CPU only, no GPU, no game files): pass What I ran:
By hand, with the synthetic BLAS/manifest/OBJ from
Nits, none blocking:
Overlap: no other open PR adds this check to AI-assisted (Claude Code). |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
bvh_match.main() now checks os.path.isdir(a.json) before opening any input and returns 2 with --json is a directory: <path> on stderr, extending the existing alias guard so a directory target cannot be selected as the report path. The new test passes a directory as --json and asserts exit 2 and the diagnostic even when both input files are missing, proving the check happens before scanning or writing.
Why merge
A directory --json previously reached the final report write and failed there after all inputs were read; early refusal matches the other report tools' behavior.
Verdict: Approve
Summary
Why mergeA directory Verdict: Approve |
Checks
os.path.isdir(a.json)up front intools/bvh_match.pymain()so passing an existing directory as--jsonexits with status 2 immediately instead of scanning candidates and writing--writebuffers before failing at report write time.Testing
python3.12 -m compileall -q tools/bvh_match.py tests/test_bvh_match.pypython3.12 -I tests/test_bvh_match.py -v(41/41 passed, including newtest_json_directory_is_refused_before_reading_inputs)AI-assisted (Gemini 4 Hydrogen Medium).