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

Đang mở Phù hợp với người mới
#883 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
70/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu từ bucket_delete trong aw-server/src/endpoints/bucket.rs, hàm này không nhận tham số force, rồi so sánh với bước kiểm tra trong aw-server viết bằng Python, bước này trả về 401 trừ khi ở chế độ kiểm thử hoặc có ?force=1. Chạy bản tái hiện bằng curl trên cả hai máy chủ để xác nhận sự khác biệt. Hoàn thành khi yêu cầu DELETE không có ?force=1 bị từ chối ngoài chế độ kiểm thử, và đã xác nhận aw-webui và aw-client-js gửi force=1.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).

Ngôn ngữ chính
Rust
Star
322
Fork
107
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
25

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ActivityWatch/aw-server-rust

Tất cả issue của ActivityWatch/aw-server-rust

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.