Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#242 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

ex_app/lib/all_tools/files.py から始め、upload_file、create_folder、move_file、copy_file、delete_file と、それらの WebDAV レスポンスを確認します。親フォルダーが存在しないケースを再現するか、まず既存のリクエスト処理を調査します。すべての非 2xx レスポンスがエラーとして報告され、成功した操作が引き続き成功として報告されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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 [
主要言語
Python
スター
24
フォーク
16
平均マージ
7日 15時間
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nextcloud/context_agent のほかの issue

nextcloud/context_agent の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。