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

Aperta Adatta ai principianti
#431 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
android, kotlin
Ambito
mobile

Direzione di ricerca

Inizia da parseCategorySeconds in workers/NotifyWorker.kt:203-229 e dal NotifyWorkerExecutionTest che fallisce, descritto nell’issue. Verifica come la funzione gestisce la risposta di androidQuery quando contiene un oggetto di errore, poi esegui il test usando {"error":"x"} come risposta fittizia del backend. Il lavoro è completato quando l’errore della query viene segnalato e il worker restituisce Result.retry() invece di indicare un esito positivo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Kotlin
Stelle
291
Fork
73
Merge medio
4g 5h
PR unite (30g)
27

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ActivityWatch/aw-android

Tutte le issue di ActivityWatch/aw-android

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.