agentscope-ai / agentscope-ai/agentscope-java

[Bug]: edit_file hangs indefinitely when old_string is empty

Đang mở
#2,446 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
area/core/agent bug
Ngôn ngữ chính
Java
Star
5.6k
Fork
1.3k
Merge trung bình
4 ngày 12 giờ
Pull request đã merge (30 ngày)
77

Mô tả

Calling edit_file with an empty old_string never returns.

Reproduction:

filesystem.edit(runtimeContext, "/notes.md", "", "replacement", false);

The loop in FilesystemUtils.countOccurrences() calls indexOf("", idx).
Because the empty string has length 0, idx never advances and the loop runs forever.

Expected behavior:
Return a normal validation error such as:
"old_string must not be empty"

Suggested fix:
Validate oldString before countOccurrences() and add a unit test with a timeout assertion.

This should be a small backward-compatible fix with no API change.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.