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

オープン 初心者向け
#431 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
android, kotlin
領域
mobile

調査の方向性

workers/NotifyWorker.kt:203-229 の parseCategorySeconds と、issue に記載されている失敗中の NotifyWorkerExecutionTest から始めてください。エラーオブジェクトを含む androidQuery の応答をこの関数がどのように処理するかを確認し、偽のバックエンド応答として {"error":"x"} を使ってテストを実行してください。クエリの失敗が表面化し、成功を報告する代わりに worker が Result.retry() を返せば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Kotlin
スター
291
フォーク
73
平均マージ
4日 5時間
マージ済み PR(30日)
27

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ActivityWatch/aw-android のほかの issue

ActivityWatch/aw-android の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。