Skip to content

fix: prefer codeflash.toml over pyproject.toml for config loading#1879

Closed
aseembits93 wants to merge 3 commits intomainfrom
fix/config-parser-codeflash-toml-priority
Closed

fix: prefer codeflash.toml over pyproject.toml for config loading#1879
aseembits93 wants to merge 3 commits intomainfrom
fix/config-parser-codeflash-toml-priority

Conversation

@aseembits93
Copy link
Contributor

Summary

  • parse_config_file() computed closest_toml_path (correctly preferring codeflash.toml at same depth) but never used it for config loading — always fell through to find_pyproject_toml() which hard-prioritizes pyproject.toml
  • This caused codeflash.toml settings (e.g. Java module-root) to be silently ignored when a pyproject.toml exists in the same or parent directory
  • Now uses closest_toml_path for loading, with explicit tie-breaking: codeflash.toml wins at same depth

Test plan

  • Added 6 tests covering: same-dir priority, single-file fallbacks, nested directory resolution, explicit --config-file bypass
  • Verified codeflash no longer reports "Functions outside module-root" for Java functions when both config files exist

🤖 Generated with Claude Code

aseembits93 and others added 2 commits March 19, 2026 11:41
parse_config_file() computed closest_toml_path but never used it for
actual config loading — it always fell through to find_pyproject_toml()
which hard-prioritizes pyproject.toml. This caused codeflash.toml
settings (e.g. Java module-root) to be ignored when pyproject.toml
exists in the same or parent directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link
Contributor

claude bot commented Mar 19, 2026

Claude finished @aseembits93's task in 3m 41s —— View job


PR Review Summary

Prek Checks

✅ Ruff (lint + format) — all passed. No auto-fixable issues.
ℹ️ Mypy errors in both changed files are pre-existing (not introduced by this PR).

Code Review

PR classification: SMALL (17 lines of production code in config_parser.py + 6 lines in git_utils.py)

codeflash/code_utils/config_parser.py — ✅ Correct fix

The core fix is correct. closest_toml_path was computed but then discarded — the function always fell through to find_pyproject_toml() regardless. The new fallback logic properly uses closest_toml_path:

if config_file_path is None and closest_toml_path is not None:
    config_file_path = closest_toml_path
else:
    config_file_path = find_pyproject_toml(config_file_path)

The explicit-path case (config_file_path not None, closest_toml_path None) still correctly delegates to find_pyproject_toml. The 6 tests cover the meaningful edge cases well.

codeflash/code_utils/git_utils.py⚠️ Unintended regression

The change on line 30 reverts a previous deliberate fix:

# Before (origin/main — intentional multi-language support):
supported_extensions = set(get_supported_extensions())

# After (this PR — accidentally reverts it):
supported_extensions = current_language_support().file_extensions

The commit message a016a5a7 undo irrelevant change suggests the author tried to undo this, but it remains in the diff. This regression means:

  • When current_language is Python, Java/JS diffs won't be detected
  • The test was renamed from test_java_diff_found_regardless_of_current_languagetest_java_diff_ignored_when_language_is_python and the assertion changed from len(result) == 1 to len(result) == 0, explicitly testing the broken behavior

The original get_supported_extensions() approach was added specifically to handle multi-language monorepos. Reverting it here will silently break Java discovery in mixed-language repos.

Suggestion: Revert the git_utils.py change and its test updates. The config_parser.py fix is independent and should be merged without them. Fix this →

Duplicate Detection

No duplicates detected. The parse_config_file and get_git_diff changes are modifications to existing functions, not new logic introduced elsewhere.

Optimization PRs

PR #1877 (⚡️ Speed up JfrProfile.get_method_ranking) has merge conflicts and is less than 3 days old — leaving open to allow the base branch to stabilize.


Last updated: 2026-03-19T19:20:00Z

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