fix: validate backtest run_dir CLI input#60
Merged
warren618 merged 2 commits intoApr 29, 2026
Conversation
BigNounce90
commented
Apr 29, 2026
BigNounce90
left a comment
Contributor
Author
There was a problem hiding this comment.
PR #60 direction good. Scope narrow. Failure mode concrete.
Fix before sending:
- Move new CLI tests under
agent/tests/. CI runspytestfrom repo root and existing suite lives there. - Use
from backtest import validationorfrom backtest.validation import _parse_run_dir. Root-levelfrom agent.backtest import validationbreaks repo conventions. - Add test for missing argument. Current code changes CLI behavior here but does not lock it down.
- Add test for non-directory path. PR body claims this case, current tests do not prove it.
Suggested patch file:
artifacts/vibe-trading-pr60-improvement.patch
Contributor
Author
|
Updated this PR to address the earlier layout/test concerns:
Local verification run:
|
warren618
approved these changes
Apr 29, 2026
warren618
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the update 🙂 I re-checked the latest PR head.
The validation CLI now rejects missing, blank, malformed, missing-path, and non-directory run_dir inputs before calling the validation runner. The new regression tests are in the project test tree and match the existing import style.
Verified locally with:
pytest agent/tests/test_validation_cli.py -qpytest agent/tests/test_validation.py agent/tests/test_validation_cli.py -qpython -m py_compile agent/backtest/validation.py agent/tests/test_validation_cli.pyruff check agent/backtest/validation.py agent/tests/test_validation_cli.py- CLI smoke checks for missing args and non-directory paths
No blockers from my side. Approved, thanks for the fix 🙌
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The standalone backtest validation entrypoint accepted
sys.argv[1]without checking that it was a usable directory path, which could surface low-level path and file errors to operators. This change adds a small argument parser that rejects empty, malformed, missing, or non-directoryrun_dirvalues with clear CLI messages before running validation.Why it matters
Without this guard, a malformed path such as an embedded-NUL argument or an accidental empty string can produce a raw exception instead of a clear operator-facing error. That makes the failure harder to diagnose and turns a narrow input mistake into an avoidable crash.
Testing
Added focused regression tests for blank, malformed, missing, and valid
run_dirarguments. The existing successful path is preserved by asserting that a real directory still parses to the samePathvalue passed intomainbefore.