Skip to content

Commit 3c1d5d1

Browse files
committed
fix: validate file path exist before return result
1 parent ef72184 commit 3c1d5d1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/api/routes_chat.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,14 @@ async def _run_openclaw_cmd():
860860
combined = "".join(collected_text_chunks)
861861
matches = file_regex.findall(combined)
862862
if matches:
863+
# 校验路径是否存在,只保留存在的
864+
valid_matches = [m for m in matches if os.path.isfile(m)]
865+
log_warning(f"{matches}")
866+
log_warning(f"{valid_matches}")
863867
deploy_check_info = json.dumps({
864868
"type": "result",
865869
"is_error": False,
866-
"result": "\n".join(f"-`{m}`"for m in matches),
870+
"result": "\n".join(f"-`{m}`" for m in valid_matches) if valid_matches else "",
867871
}, ensure_ascii=False)
868872
chunk = gpt_stream_chunk(deploy_check_info)
869873
yield f"data: {json.dumps(chunk, ensure_ascii=False)}\n\n".encode("utf-8")

0 commit comments

Comments
 (0)