Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

File tools (upload/create folder/move/copy/delete) always report success, even when the WebDAV request fails

Đang mở Phù hợp với người mới
#242 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

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

  1. Ask the agent: "Create a file named test.md in folder /does-not-exist with content: hello", approve the action.
  2. 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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nextcloud/context_agent

Tất cả issue của nextcloud/context_agent

Issue tương tự

Thêm issue về Python

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.