Fix: Handle test paths outside tests_root in verifier.py#1991
Conversation
When JavaScript/TypeScript support generates test files in __tests__ subdirectories adjacent to source files (e.g., src/foo/__tests__/codeflash-generated/), these test files are not within the configured tests_project_rootdir. Previously, verifier.py:37 called module_name_from_file_path() without handling the ValueError that occurs when the test path is outside tests_root, causing optimization runs to crash. This fix adds try-except handling with a fallback to using just the filename, matching the pattern already used in javascript/parse.py:330-333. Fixes trace ID: 84f5467f-8acf-427f-b468-02cb3342097e Changes: - codeflash/verification/verifier.py:37-48: Added try-except for path computation - tests/verification/test_verifier_path_handling.py: Added unit tests Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Claude finished @mohammedahmed18's task in 2m 39s —— View job PR Review SummaryPrek Checks
Code ReviewThe fix in One observation (not blocking): The second test Note: Duplicate DetectionNo duplicates detected. The fallback pattern ( Last updated: 2026-04-04T07:52Z |
Summary
Fixes a bug where JavaScript/TypeScript optimization runs crash with when test files are generated outside the configured .
Problem
JavaScript support's method places test files in subdirectories adjacent to source files (e.g., ). However, assumes test files are within and calls without handling the that occurs when this assumption is violated.
Root Cause
/workspace/target/src/gateway/server/__tests__/codeflash-generated/test_foo.test.tstests_project_rootdiris:/workspace/target/testrelative_to()raisesValueErrorSolution
Added try-except handling with fallback to using just the filename, matching the pattern already used in .
Changes
Testing
✅ Unit tests pass
✅
uv run prekpasses (no linting/type errors)✅ Verified with actual rerun:
codeflash --rerun 84f5467f-8acf-427f-b468-02cb3342097eTrace ID
84f5467f-8acf-427f-b468-02cb3342097e
🤖 Generated with Claude Code