File tools (upload/create folder/move/copy/delete) always report success, even when the WebDAV request fails
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Start in ex_app/lib/all_tools/files.py, reviewing upload_file, create_folder, move_file, copy_file, and delete_file along with their WebDAV responses. Reproduce the missing-parent-folder case or inspect the existing request handling first. Done means every non-2xx response is reported as an error and successful operations still report success.
Written by the indexing model from the issue text.
Description
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 [
- Dominant language
- Python
- Stars
- 24
- Forks
- 16
- Avg merge
- 7d 15h
- Merged PRs (30d)
- 4
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextcloud/context_agent
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
nextcloud/context_agent#240 ·
-
find_person_in_contacts fails with Niquests content argument and cannot serialize vCard AddressOpenbug
Difficulty 2/5 Half a day Newbie friendliness 76/100
nextcloud/context_agent#217 · 3 comments ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 72/100
nextcloud/context_agent#241 ·
-
list skills toolOpenenhancement priority normal
Difficulty 5/5 Over a week Newbie friendliness 35/100
nextcloud/context_agent#239 · 2 comments · 1 reaction ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 67/100
nextcloud/context_agent#231 · 2 comments ·
All issues in nextcloud/context_agent
Similar issues
-
bug status/needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
prowler-cloud/prowler#12887 · 1 comment ·
Maintainers usually reply within 1 day
-
area: desktop platform: macos priority: p3 status: ready type: enhancement
Difficulty 1/5 Under an hour Newbie friendliness 92/100
use-agent-os/agent-os#3484 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
open-telemetry/opentelemetry-python-contrib#5113 · 2 comments · 2 reactions ·
Maintainers usually reply within 1 day
-
external
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
langchain-ai/docs#6255 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day