File tools (upload/create folder/move/copy/delete) always report success, even when the WebDAV request fails
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 85/100
Direzione di ricerca
Inizia in ex_app/lib/all_tools/files.py esaminando upload_file, create_folder, move_file, copy_file e delete_file insieme alle relative risposte WebDAV. Riproduci il caso della cartella principale mancante oppure analizza prima la gestione delle richieste esistente. Il lavoro è completo quando ogni risposta non-2xx viene segnalata come errore e le operazioni riuscite continuano a segnalare il successo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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 [
- Lingua principale
- Python
- Stelle
- 24
- Fork
- 16
- Merge medio
- 7g 15h
- PR unite (30g)
- 4
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nextcloud/context_agent
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nextcloud/context_agent#240 · 1 commento ·
-
find_person_in_contacts fails with Niquests content argument and cannot serialize vCard AddressApertabug
Difficoltà 2/5 Mezza giornata Idoneità per principianti 76/100
nextcloud/context_agent#217 · 3 commenti ·
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
nextcloud/context_agent#241 · 1 commento ·
-
list skills toolApertaenhancement priority normal
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
nextcloud/context_agent#239 · 2 commenti · 1 reazione ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 67/100
nextcloud/context_agent#231 · 2 commenti ·
Tutte le issue di nextcloud/context_agent
Issue simili
-
Claiming namespace `apoint`Apertanamespace operations
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
EclipseFdn/open-vsx.org#13573 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
collective/icalendar#1854 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
rancher/rancher-ai-agent#412 ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TUDelftGeodesy/DePSI#134 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
HenriquesLab/rxiv-maker#335 ·