NotifyWorker treats a failed category query as zero time and reports success

Đang mở Phù hợp với người mới
#431 0 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 2 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
84/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ệ
android, kotlin
Lĩnh vực
mobile

Hướng nghiên cứu

Bắt đầu với parseCategorySeconds trong workers/NotifyWorker.kt:203-229 và NotifyWorkerExecutionTest đang thất bại được mô tả trong issue. Kiểm tra cách hàm xử lý phản hồi androidQuery khi phản hồi chứa một đối tượng lỗi, sau đó chạy kiểm thử với {"error":"x"} làm phản hồi giả từ backend. Công việc hoàn tất khi lỗi truy vấn được thể hiện và worker trả về Result.retry() thay vì báo thành công.

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

Mô tả

bug

When the native query fails, NotifyWorker treats the day as zero time and returns Result.success(). Category alerts for that run are skipped and nothing records the failure.

parseCategorySeconds (workers/NotifyWorker.kt:203-229) passes the androidQuery result to JSONArray(...). On a query failure the native side returns {"error": "…"} instead (aw-server-rust aw-server/src/android/mod.rs, create_error_object). This happens, for example, when the aw-watcher-android bucket is missing, when a category regex doesn't compile, or when the datastore errors. The exception is logged and swallowed, and the function returns {null: 0.0}. No threshold can be crossed, so the worker reports success instead of retry().

Failing test (NotifyWorkerExecutionTest, using its fake backend): make androidQuery return {"error":"x"} and expect Result.retry(). Today the result is Result.success(). At the unit level:

@Test
fun queryErrorObjectIsNotZeroSeconds() {
    assertThrows(Exception::class.java) { parseCategorySeconds("""{"error":"x"}""") }
}

It fails today because the function returns {null=0.0}.

Fix direction: detect the error object and surface it as a failure, so the existing retry/backoff path runs.

Same parse pattern as the widget issue #430; filed separately because the symptom and fix site differ.

Priority: medium (alerts silently skipped). This repo only has a priority: high label, so no priority label is set.

fingerprint: workers/NotifyWorker.kt — androidQuery error object counted as 0 seconds, success instead of retry

Found by code review on master 3b820d61. I verified the trigger path against aw-server-rust 67432e66. I have not run it on a device.

Ngôn ngữ chính
Kotlin
Star
291
Fork
73
Merge trung bình
4 ngày 5 giờ
Pull request đã merge (30 ngày)
27

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-android

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

Issue tương tự

Thêm issue về Kotlin

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.