From 58f84d0d46d3bb8e9f084146f0c2ad171e1c5662 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Wed, 21 Oct 2026 10:20:04 +0200 Subject: [PATCH] fix(files): Make sure webdav failures raise an error fixes #242 Assisted-by: ClaudeCode:claude-opus-5.5 Signed-off-by: Marcel Klehr --- ex_app/lib/all_tools/files.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ex_app/lib/all_tools/files.py b/ex_app/lib/all_tools/files.py index e5ffb738..ec69482d 100644 --- a/ex_app/lib/all_tools/files.py +++ b/ex_app/lib/all_tools/files.py @@ -78,6 +78,7 @@ async def get_file_content(file_path: str): "Content-Type": "application/json", }) + response.raise_for_status() return response.text @tool @@ -156,6 +157,7 @@ async def upload_file(path: str, content: str): "Content-Type": "text/plain", }, data=content) + response.raise_for_status() return {"status": "success", "path": path} @tool @@ -173,6 +175,7 @@ async def create_folder(path: str): "Content-Type": "application/json", }) + response.raise_for_status() return {"status": "success", "path": path} @tool @@ -193,6 +196,7 @@ async def move_file(source_path: str, destination_path: str): "Destination": f"{nc.app_cfg.endpoint}/remote.php/dav/files/{user_id}/{destination_path}", }) + response.raise_for_status() return {"status": "success", "from": source_path, "to": destination_path} @tool @@ -213,6 +217,7 @@ async def copy_file(source_path: str, destination_path: str): "Destination": f"{nc.app_cfg.endpoint}/remote.php/dav/files/{user_id}/{destination_path}", }) + response.raise_for_status() return {"status": "success", "from": source_path, "to": destination_path} @tool @@ -237,6 +242,7 @@ async def get_file_id_by_path(file_path: str) -> int: headers={"Content-Type": "application/xml; charset=utf-8", "Depth": "0"}, data=propfind_body, ) + propfind_response.raise_for_status() root = ET.fromstring(propfind_response.text) fileid_element = root.find(".//{http://owncloud.org/ns}fileid") @@ -276,6 +282,7 @@ async def get_file_path_by_id(file_id: int) -> str: headers={"Content-Type": "text/xml; charset=utf-8"}, data=search_body, ) + search_response.raise_for_status() root = ET.fromstring(search_response.text) href_element = root.find(".//{DAV:}response/{DAV:}href") @@ -313,6 +320,7 @@ async def convert_file(source_path: str, target_mime_type: str, destination_path headers={"Content-Type": "application/xml; charset=utf-8", "Depth": "0"}, data=propfind_body, ) + propfind_response.raise_for_status() root = ET.fromstring(propfind_response.text) fileid_element = root.find(".//{http://owncloud.org/ns}fileid") @@ -347,6 +355,7 @@ async def delete_file(path: str): "Content-Type": "application/json", }) + response.raise_for_status() return {"status": "success", "deleted": path} return [