Skip to content

Fix package.json config overriding closer pyproject.toml in monorepos - #1478

Merged
KRRT7 merged 4 commits into
mainfrom
fix-package-json-config-override
Feb 13, 2026
Merged

Fix package.json config overriding closer pyproject.toml in monorepos#1478
KRRT7 merged 4 commits into
mainfrom
fix-package-json-config-override

Conversation

@KRRT7

@KRRT7 KRRT7 commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 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.

Fixes the CI failure in codeflash-ai/codeflash-internal#2335.

Test plan

  • Existing test_config_js.py tests pass (81 passed)
  • Existing test_config.py tests pass (22 passed)
  • Existing test_tracer.py and test_formatter.py tests pass (52 passed)

KRRT7 and others added 3 commits February 13, 2026 04:48
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.
@claude

claude Bot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

PR Review Summary

Prek Checks

✅ All prek checks pass (ruff check, ruff format).

Mypy Checks

✅ Fixed 5 pre-existing mypy errors in config_parser.py (committed and pushed):

  • Fixed Item | Container assignment by using isinstance guard + dict() conversion
  • Fixed incompatible loop variable reassignments by using distinct variable names per loop
  • Fixed Any | None indexing by extracting formatter_cmds to a local variable

Code Review

No critical issues found. The PR correctly fixes the monorepo config resolution by:

  • Comparing package.json and pyproject.toml proximity to CWD using path depth
  • Using >= for ties (favoring package.json — preserves backward compat for same-directory cases)
  • Both find_package_json() and find_closest_config_file() use the same upward-search-from-CWD algorithm, so the depth comparison is valid

Minor note: The new monorepo resolution logic (lines 92-120) has no test coverage. Consider adding tests for the case where both package.json and pyproject.toml exist at different depths.

Test Coverage

File Stmts Miss Coverage
codeflash/code_utils/config_parser.py 136 50 63%

Overall project coverage: 79%

New lines not covered by tests:

  • Lines 99-105: Depth comparison logic when both config files exist
  • Lines 108-120: use_package_json branch with formatter validation

⚠️ The new config resolution logic (the core change of this PR) is not exercised by any tests. While the overall file coverage (63%) is below the 75% threshold, most uncovered lines are pre-existing. The PR-specific uncovered code is ~15 lines.

Codeflash Optimization PRs

No optimization PRs have all CI checks passing — none merged.


Last updated: 2026-02-13T

@KRRT7
KRRT7 merged commit 1d9824c into main Feb 13, 2026
22 of 25 checks passed
@KRRT7
KRRT7 deleted the fix-package-json-config-override branch February 13, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant