File tools (upload/create folder/move/copy/delete) always report success, even when the WebDAV request fails
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
Hướng nghiên cứu
Bắt đầu trong ex_app/lib/all_tools/files.py, xem xét upload_file, create_folder, move_file, copy_file và delete_file cùng với các phản hồi WebDAV của chúng. Tái hiện trường hợp thiếu thư mục cha hoặc trước tiên kiểm tra phần xử lý request hiện có. Công việc được hoàn tất khi mọi phản hồi không phải 2xx đều được báo cáo là lỗi và các thao tác thành công vẫn tiếp tục báo cáo thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version: context_agent 2.8.0
Steps to reproduce
- Ask the agent: "Create a file named test.md in folder /does-not-exist with content: hello", approve the action.
- The agent answers "I have successfully created the file…" but no file exists (the WebDAV PUT returned an error because the parent folder is missing).
Cause: ex_app/lib/all_tools/files.py — upload_file, create_folder, move_file, copy_file, delete_file send the request and
return {"status": "success", ...} without looking at response.status_code. The model then tells the user the action succeeded.
Impact: users are told work was done when it was not (silent data loss / false confirmation).
Fix (tested): check the status code and return an error object for non-2xx so the model reports the failure. Patch below.
Patch (tested on a test instance):
--- a/ex_app/lib/all_tools/files.py
+++ b/ex_app/lib/all_tools/files.py
@@ -21,6 +21,14 @@
return path
+def _dav_error(response):
+ """Return an error dict if the WebDAV request did not succeed (non-2xx), otherwise None."""
+ code = getattr(response, 'status_code', None)
+ if code is None or code >= 300:
+ return {"status": "error", "http_status": code, "message": "The WebDAV request failed. Nothing was changed. Tell the user it did not work."}
+ return None
+
+
async def get_tools(nc: AsyncNextcloudApp):
@tool
@@ -160,6 +168,9 @@
"Content-Type": "text/plain",
}, data=content)
+ err = _dav_error(response)
+ if err:
+ return err
return {"status": "success", "path": path}
@tool
@@ -177,6 +188,9 @@
"Content-Type": "application/json",
})
+ err = _dav_error(response)
+ if err:
+ return err
return {"status": "success", "path": path}
@tool
@@ -196,6 +210,9 @@
"Destination": f"{nc.app_cfg.endpoint}/remote.php/dav/files/{user_id}/{destination_path}",
})
+ err = _dav_error(response)
+ if err:
+ return err
return {"status": "success", "from": source_path, "to": destination_path}
@tool
@@ -215,6 +232,9 @@
"Destination": f"{nc.app_cfg.endpoint}/remote.php/dav/files/{user_id}/{destination_path}",
})
+ err = _dav_error(response)
+ if err:
+ return err
return {"status": "success", "from": source_path, "to": destination_path}
@tool
@@ -348,6 +368,9 @@
"Content-Type": "application/json",
})
+ err = _dav_error(response)
+ if err:
+ return err
return {"status": "success", "deleted": path}
return [
- Ngôn ngữ chính
- Python
- Star
- 24
- Fork
- 16
- Merge trung bình
- 7 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nextcloud/context_agent
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nextcloud/context_agent#240 ·
-
find_person_in_contacts fails with Niquests content argument and cannot serialize vCard AddressĐang mởbug
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 76/100
nextcloud/context_agent#217 · 3 bình luận ·
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
nextcloud/context_agent#241 ·
-
list skills toolĐang mởenhancement priority normal
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
nextcloud/context_agent#239 · 2 bình luận · 1 reaction ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
nextcloud/context_agent#231 · 2 bình luận ·
Tất cả issue của nextcloud/context_agent
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
qgis/QGIS-Plugins-Website#459 ·
-
bug severity:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bot-found bug priority: P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
madenvel/KalinkaPlayer#179 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ls1intum/edutelligence#1098 ·
Maintainer thường phản hồi trong vòng 1 ngày