Reproduced defects from a REST/datastore bug hunt: delete race, PUT/log 500s, CSV surrogate truncation, query-cache key
メンテナーはふだん 5 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 12/100
調査の方向性
This is a bundle of eight separate defects, not one starting point. Begin with the DELETE /api/0/buckets/<id> handler in rest.py and Datastore.delete_bucket in aw-core, where the cached bucket handle is dropped before the storage delete commits. Each item needs its own reproduction and fix, and several touch locking and aw-core, so a maintainer should choose one item to start with. Done means each reproduced case returns the documented status code and has a regression test.
索引モデルが issue の本文から書いたものです。
説明
These are defects from a bug hunt over aw-server master (0ab73fe). Each one was triggered by a test against the Flask test client or a live werkzeug server. Three others are fixed in #230, #231 and #232. This issue lists the rest so none are lost. Open PRs and issues were checked for overlap.
1. A request during DELETE /api/0/buckets/<id> leaves a zombie bucket that returns 500 until it's re-created
- Root cause:
Datastore.delete_bucket(aw-core) drops its cachedBuckethandle before the storage delete commits. A concurrent request (heartbeat or read, each on its own peewee connection) still sees the bucket and re-caches the handle. - After the delete returns 200,
GET /buckets/no longer lists the bucket, butGET /buckets/<id>,/events, heartbeat andPOST /eventsall return 500 instead of 404. - Trigger: delete a 300k-event bucket (about 0.4 s) while its watcher heartbeats. Deleting a large bucket from the web UI with its watcher running is enough.
- Two concurrent DELETEs give
[200, 500]instead of[200, 404]. - Fix direction: drop the cached handle after the storage delete (aw-core), and run
check_bucket_existsunder the write lock for writes.
2. PUT /api/0/buckets/<id> with a partial body returns 500
rest.pyindexesdata["type"],["client"],["hostname"]and["data"]directly, although theupdate_bucketmodel marks every field optional.{"hostname": "x"}givesKeyError, andnullor[1]giveTypeError; all three surface as 500. Draft #201 happens to switch this to.get.
3. GET /api/0/log always returns 500
get_logcallsjson.loadson each line, but the file handler writes human-readable lines.- With no log file, it calls
open(None). - It also returns
(payload, 200)inside another(…, 200).
4. CSV export returns 200 and then a truncated body when event data contains a lone UTF-16 surrogate
POST /eventsaccepts{"title": "bad\ud83d"}, and JSON export handles it. In/export/csv, werkzeug's UTF-8 encode raises partway through the stream.- The client gets
IncompleteRead, and every row after that event is silently missing.
5. The query cache key misses inputs that change the result
QueryCache.keyis the query text plus the UTC-normalized period. Three cases return stale results:?name=(exposed asNAME):RETURN = NAME;returns the first caller's name to later callers.STARTTIME/ENDTIMEkeep the client's offset, soRETURN = STARTTIME;for…T02:00:00+02:00is served to a later request for…T00:00:00Z.- A query that reassigns
STARTTIMEreads outside its period, so writes there don't invalidate it.
- aw-webui uses none of these patterns today, so this is low impact.
6. Concurrent first get_device_id() calls return an empty or different id
api.pydoes an exists check, thenopen("w"), then a write, with no lock.- Fresh data dir, 8 threads calling
GET /info: 185 of 300 trials returned""to some caller. - A
!localbucket created then keeps a wrongdata.device_id. This only affects first run.
7. Deleting a bucket during GET /api/0/export truncates the export after the 200
- The bucket list is captured up front, and
self.db[bid]is resolved lazily in the generator. - A bucket deleted mid-stream raises
KeyErrorand produces an unterminated JSON backup.
8. Finite but overflowing values return 500 instead of 400 (same class as #214)
- An event with
duration: 1e12, or with a timestamp of9999-12-31T23:59:59Zplus a duration, raisesOverflowErrorinevent_range._parse_eventonly catchesValueErrorandTypeError. pulsetime=1e12passes the #207isfinitecheck, then overflows inheartbeat_merge.
Refuted / not filed:
- Two aw-core findings, the reversed 10-second SQLite commit check and
endtimerounded 1 ms past the period end, reproduce only with the aw-core commit aw-server currently pins. Upstream aw-core already fixed both (the second in aw-core#162), and #229 repins it. - Out-of-order heartbeat caching is deliberate and matches aw-server-rust.
- 主要言語
- Python
- スター
- 129
- フォーク
- 105
- 平均マージ
- 4日 23時間
- マージ済み PR(30日)
- 17
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ActivityWatch/aw-server のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
ActivityWatch/aw-server#234 ·
メンテナーはふだん 5 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 51/100
ActivityWatch/aw-server#213 ·
メンテナーはふだん 5 日以内に返信
-
Return structured 400 when event storage rejects a foreign-bucket ID対応中かも @TimeToBuildBob が 28 日前に担当しました。 オープン
難易度 4/5 1〜2日 初心者へのやさしさ 35/100
ActivityWatch/aw-server#211 ·
メンテナーはふだん 5 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
ActivityWatch/aw-server#187 · コメント 2 件 ·
メンテナーはふだん 5 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
ActivityWatch/aw-server#86 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
ActivityWatch/aw-server の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mloda-ai/mloda-plugin-template#206 ·
メンテナーはふだん 1 日以内に返信
-
integration: websocket_api
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
home-assistant/core#194618 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Shorten and organize the README around reader tasks対応中かも @msaad00 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
5hyuns/maya-workflow-kit-for-blender#568 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
letsrevel/revel-backend#1558 ·
メンテナーはふだん 1 日以内に返信