Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion codeflash/api/aiservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,17 @@ def code_repair(self, request: AIServiceCodeRepairRequest) -> OptimizedCandidate
"""
console.rule()
try:
# Filter out test diffs where test_src_code is None since aiservice requires it to be a string
valid_test_diffs = [diff for diff in request.test_diffs if diff.test_src_code is not None]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aseembits93 can you review this? why would this be None? is there a root cause fix for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@misrasaurabh1 this is the expected schema on the backend


class TestDiff(Schema):
    test_src_code: str

this is the schema on cli

@dataclass
class TestDiff:
    test_src_code: Optional[str] = None

i'll fix it on the backend, we can close this one

if not valid_test_diffs:
logger.warning("No test diffs with valid test_src_code found, skipping code repair")
return None
payload = {
"optimization_id": request.optimization_id,
"original_source_code": request.original_source_code,
"modified_source_code": request.modified_source_code,
"trace_id": request.trace_id,
"test_diffs": request.test_diffs,
"test_diffs": valid_test_diffs,
"language": request.language,
}
response = self.make_ai_service_request("/code_repair", payload=payload, timeout=self.timeout)
Expand Down
Loading