Bucket DELETE ignores ?force=1: aw-server-rust deletes without it (Python refuses with 401)

Aperta Adatta ai principianti
#883 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
api

Direzione di ricerca

Inizia da bucket_delete in aw-server/src/endpoints/bucket.rs, che non accetta il parametro force, e confrontalo con il controllo del aw-server Python che restituisce 401 a meno che non sia in modalità test o non ci sia ?force=1. Esegui la riproduzione con curl su entrambi i server per confermare la differenza. È completato quando una DELETE senza ?force=1 viene rifiutata al di fuori della modalità test, e aw-webui e aw-client-js risultano inviare force=1.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

DELETE /api/0/buckets/<id> on aw-server-rust deletes the bucket and all its events without ?force=1. The Python aw-server refuses the same request outside testing mode, and the docs say force=1 is required (REST reference, "Delete").

This matters because clients rely on the guard. aw-client's delete_bucket(bucket_id, force=False) sends ?force=1 only when you pass force=True. On aw-server-rust, the default call is irreversible.

Repro (v0.14.3 linux release, normal mode, isolated XDG_* dirs):

aw-server-rust --port 5651 &   # and the bundled Python aw-server on 5652
for p in 5651 5652; do
  curl -s -o /dev/null -X POST -H Content-Type:application/json \
    -d '{"client":"t","type":"t","hostname":"h"}' http://127.0.0.1:$p/api/0/buckets/vb
  curl -s -w " <- DELETE without force: %{http_code}\n" -X DELETE http://127.0.0.1:$p/api/0/buckets/vb
  curl -s -o /dev/null -w "GET after: %{http_code}\n" http://127.0.0.1:$p/api/0/buckets/vb
done
 <- DELETE without force: 200          # aw-server-rust
GET after: 404                         # bucket and events are gone
{"message": "Deleting buckets is only permitted if aw-server is running in testing mode or if ?force=1"}
 <- DELETE without force: 401          # Python aw-server
GET after: 200

?force=0 also deletes on aw-server-rust. bucket_delete in aw-server/src/endpoints/bucket.rs takes no force parameter at all.

Expected: the same guard as Python: refuse without ?force=1 unless the server runs with --testing.

One compatibility point to check first: whether aw-webui and aw-client-js send force=1 when deleting a bucket from the UI. If they don't, they need the parameter in the same change.

Found during a docs-vs-reality pass of the REST API docs (ActivityWatch/docs#224).

Lingua principale
Rust
Stelle
322
Fork
107
Merge medio
2g 16h
PR unite (30g)
25

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ActivityWatch/aw-server-rust

Tutte le issue di ActivityWatch/aw-server-rust

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.