fix: route Java/JavaScript/TypeScript to Optimizer instead of Python tracer#1398
Merged
mashraf-222 merged 1 commit intoomni-javafrom Feb 5, 2026
Merged
fix: route Java/JavaScript/TypeScript to Optimizer instead of Python tracer#1398mashraf-222 merged 1 commit intoomni-javafrom
mashraf-222 merged 1 commit intoomni-javafrom
Conversation
…tracer Java, JavaScript, and TypeScript files were incorrectly being routed through the Python tracing module when running `codeflash optimize --file <file>`, causing a FileNotFoundError when the tracer attempted to execute CLI args as Python scripts. This fix adds language detection at the start of tracer.py main() function. When a non-Python file is detected (Java, JS, TS), the function: 1. Detects the file language using get_language_support() 2. Parses and processes args properly with process_pyproject_config() 3. Routes directly to optimizer.run_with_args() instead of Python tracing Java and JS/TS use their own test runners (Maven/JUnit, Jest) and should never go through Python tracing. This fix unblocks all Java E2E optimization flows. Issue: Java optimization failed with "FileNotFoundError: '--file'" from tracing_new_process.py:855 Root cause: tracer.py had no language check before invoking Python-specific tracing subprocess Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Problem Fixed
Java, JavaScript, and TypeScript optimization was broken. When running
codeflash optimize --file <file>on non-Python files, the CLI crashed with:Impact: Blocked all Java E2E optimization flows
Root Cause
tracer.pyhad no language check before invoking the Python tracer. Allcodeflash optimizecommands were routed throughtracing_new_process.py(Python-specific), regardless of the target file's language.When Java files were passed with
--file, the tracer tried to execute--fileas a Python script, causing the error.Solution
Added language detection at the start of
tracer.py:main():get_language_support(file_path)optimizer.run_with_args()instead of Python tracingJava and JS/TS use their own test runners (Maven/JUnit, Jest) and should never go through Python tracing.
Code Changes
File:
codeflash/tracer.pyprocess_pyproject_config()previous_checkpoint_functions = Nonefor single-file optimizationTesting
Before fix:
$ codeflash optimize --file QuickSort.java --function sort FileNotFoundError: [Errno 2] No such file or directory: '--file' ❌ Failed to trace. Exiting...After fix:
Impact
✅ Unblocks: All Java E2E optimization flows
✅ Unblocks: JavaScript/TypeScript optimization flows
✅ Fixes: Future Java testing and validation work
🤖 Generated with Claude Code