Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#242 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
85/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
backend

Línea de trabajo

Empieza en ex_app/lib/all_tools/files.py revisando upload_file, create_folder, move_file, copy_file y delete_file junto con sus respuestas de WebDAV. Reproduce el caso de una carpeta principal inexistente o inspecciona primero el manejo de las solicitudes existente. La tarea estará completa cuando toda respuesta que no sea 2xx se notifique como un error y las operaciones exitosas sigan notificándose como exitosas.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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 [
Lenguaje dominante
Python
Estrellas
24
Forks
16
Merge medio
7 d 15 h
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de nextcloud/context_agent

Todos los issues de nextcloud/context_agent

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.