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

未关闭 适合新手
#883 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
70/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
api

调研方向

从 aw-server/src/endpoints/bucket.rs 中的 bucket_delete 开始,它不接受 force 参数,然后将其与 Python 版 aw-server 的守卫进行比较,后者在非测试模式且没有 ?force=1 时返回 401。对两个服务器运行 curl 复现,以确认差异。完成标准是:在非测试模式下,不带 ?force=1 的 DELETE 会被拒绝,并且确认 aw-webui 和 aw-client-js 会发送 force=1。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Rust
星标
322
派生
107
平均合并
2 天 16 小时
30 天内合并 PR
25

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ActivityWatch/aw-server-rust 的其他 Issue

查看 ActivityWatch/aw-server-rust 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。