endpoints: a far-future event panics inside write_lock and poisons it, so every later write returns 500 until restart
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start in aw-server/src/endpoints/bucket.rs, where bucket_events_create and bucket_events_heartbeat call event_range() while holding write_lock. The overflow comes from Event::calculate_endtime() in aw-models/src/event.rs (line 43), which uses plain +. Reproduce with the Rocket local client using a far-future timestamp, then confirm the endpoint returns 400 and that later writes still succeed.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In aw-server/src/endpoints/bucket.rs, both bucket_events_create and bucket_events_heartbeat call event_range() while holding state.write_lock (write_lock.lock().unwrap(), lines ~179 and ~224). event_range() calls Event::calculate_endtime() (aw-models/src/event.rs:43), which adds the duration with a plain +. That addition panics when the result overflows chrono's range.
An event with a far-future timestamp and a valid duration (< 292 years) therefore panics inside the lock and poisons the Mutex. Every later lock().unwrap() then panics too, so all event writes return 500 until the server restarts: every watcher's heartbeats, event creates, single and bulk deletes. The datastore's own range check (event_nanos) would return a clean 400, but it runs after this point.
Repro (Rocket local client, upstream master ea6f09c):
POST /api/0/buckets/aw-watcher-web-firefox/heartbeat?pulsetime=1
{"timestamp":"+262000-01-01T00:00:00Z","duration":9e9,"data":{}}
-> 500 (panic: `DateTime + TimeDelta` overflowed)
POST /api/0/buckets/aw-watcher-web-firefox/heartbeat?pulsetime=1
{"timestamp":"2026-01-01T00:00:00Z","duration":0,"data":{}}
-> 500 (and the same for POST .../events and DELETE .../events/1)
POST .../events with the same far-future event gives the same result. A browser extension can send it too: the default CORS rule admits moz-extension:// origins for aw-watcher-web-* buckets. So one buggy client clock or extension takes data collection down for every watcher, silently, until restart.
Suggested fix
- Compute the range with
checked_add_signedand return 400 before taking the lock. Or validate the event's range first and take the lock after. - Stop the lock from failing permanently, e.g.
lock().unwrap_or_else(PoisonError::into_inner). It guards only ordering and protects no invariant that a panic could break.
Found in a verified review pass over the endpoints. No PR from me yet, because I already have three open from this pass (#869, #870, #871).
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ActivityWatch/aw-server-rust
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
ActivityWatch/aw-server-rust#883 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
ActivityWatch/aw-server-rust#872 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ActivityWatch/aw-server-rust#798 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
query: categorize rules can pin unbounded memory in the regex cache and run past query_timeoutCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
ActivityWatch/aw-server-rust#893 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
aw-client CLI ignores aw-client.toml host/portCó thể đã có người làm @TimeToBuildBob đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
ActivityWatch/aw-server-rust#888 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ActivityWatch/aw-server-rust
Issue tương tự
-
area: cli good first issue type: feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
renaming a provider to a taken name fails with a raw sql errorCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởarea:storage kind:bug priority:p3 ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug bugfix
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
storytold/photocraft#16975 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
expo/exact#1716 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày