FoundationAgents/MetaGPT · error · ValueError
Only code reviews for Python and Java languages are supporte
Error message
Only code reviews for Python and Java languages are supported.
What it means
Raised by the code-review action when valid_patch_count == 0 after iterating the patch set — i.e. no patched file in the patch was recognized as reviewable. The reviewer only reviews patches it can parse and map to supported languages (Python/Java), so an all-filtered patch set yields zero reviews and this error signals that nothing was reviewable.
Source
Thrown at metagpt/ext/cr/actions/code_review.py:205
valid_patch_count += 1
else:
continue
group_points = [points[i : i + 3] for i in range(0, len(points), 3)]
for group_point in group_points:
points_str = "id description\n"
points_str += "\n".join([f"{p.id} {p.text}" for p in group_point])
prompt = CODE_REVIEW_PROMPT_TEMPLATE.format(patch=str(patched_file), points=points_str)
resp = await self.llm.aask(prompt)
json_str = parse_json_code_block(resp)[0]
comments_batch = json.loads(json_str)
if comments_batch:
patched_file_path = patched_file.path
for c in comments_batch:
c["commented_file"] = patched_file_path
comments.extend(comments_batch)
if valid_patch_count == 0:
raise ValueError("Only code reviews for Python and Java languages are supported.")
return comments
async def run(self, patch: PatchSet, points: list[Point], output_file: str):
patch: PatchSet = rm_patch_useless_part(patch)
patch: PatchSet = add_line_num_on_patch(patch)
result = []
async with EditorReporter(enable_llm_stream=True) as reporter:
log_cr_output_path = Path(output_file).with_suffix(".log")
await reporter.async_report(
{"src_path": str(log_cr_output_path), "filename": log_cr_output_path.name}, "meta"
)
comments = await self.cr_by_points(patch=patch, points=points)
log_cr_output_path.parent.mkdir(exist_ok=True, parents=True)
async with aiofiles.open(log_cr_output_path, "w", encoding="utf-8") as f:
await f.write(json.dumps(comments, ensure_ascii=False, indent=2))
await reporter.async_report(log_cr_output_path)View on GitHub (pinned to 11cdf466d0)
Solutions
- Confirm the patch actually contains Python or Java file diffs and is a valid unified diff
- If reviewing other languages is intended, this action does not support them — skip the tool for such PRs instead of erroring
- Inspect the patch after rm_patch_useless_part to see whether all hunks were stripped as useless parts
Defensive patterns
Strategy: validation
Validate before calling
reviewable = [f for f in patch if str(f.path).endswith((".py", ".java"))]
if not reviewable:
skip review instead of calling run() Type guard
def patch_has_reviewable_files(patch) -> bool:
return any(str(f.path).endswith((".py", ".java")) for f in patch) Try / catch
try:
comments = await action.run(patch, points, output_file)
except ValueError as e:
if "Only code reviews" in str(e):
comments = [] # nothing reviewable in this patch
else:
raise Prevention
- Pre-filter patches to Python/Java files before invoking the reviewer
- Do not run the CR action on doc-only or unsupported-language PRs
When it happens
Trigger: Calling run(patch, points, output_file) with a PatchSet whose files are all non-Python/Java (or whose hunks rm_patch_useless_part/add_line_num_on_patch stripped out), so every file is skipped and valid_patch_count stays 0.
Common situations: Running the CR tool on a PR that only touches JS/Go/Rust/docs; feeding a patch for a repo whose diff context lines confuse the parser; passing an empty patch.
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/65f00dc21e64e3c7.
Report an issue: GitHub.