Fix package.json config overriding closer pyproject.toml in monorepos - #1478
Conversation
In parse_config_file(), package.json was always checked first by walking up from CWD. In monorepos with both a root package.json and a nested pyproject.toml with [tool.codeflash], the JS config would win and set pytest_cmd to "jest", causing Python function optimization to crash with FileNotFoundError: 'jest'. Now both config files are located first, and the one closer to CWD is preferred, so a pyproject.toml in the working directory takes precedence over a parent-directory package.json.
PR Review SummaryPrek Checks✅ All prek checks pass (ruff check, ruff format). Mypy Checks✅ Fixed 5 pre-existing mypy errors in
Code ReviewNo critical issues found. The PR correctly fixes the monorepo config resolution by:
Minor note: The new monorepo resolution logic (lines 92-120) has no test coverage. Consider adding tests for the case where both Test Coverage
Overall project coverage: 79% New lines not covered by tests:
Codeflash Optimization PRsNo optimization PRs have all CI checks passing — none merged. Last updated: 2026-02-13T |
Summary
parse_config_file(),package.jsonwas always checked first by walking up from CWD. In monorepos with both a rootpackage.jsonand a nestedpyproject.tomlwith[tool.codeflash], the JS config would win and setpytest_cmdtojest, causing Python function optimization to crash withFileNotFoundError: 'jest'.pyproject.tomlin the working directory takes precedence over a parent-directorypackage.json.Fixes the CI failure in codeflash-ai/codeflash-internal#2335.
Test plan
test_config_js.pytests pass (81 passed)test_config.pytests pass (22 passed)test_tracer.pyandtest_formatter.pytests pass (52 passed)