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

Abierto Apto para principiantes
#431 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
android, kotlin
Área
mobile

Línea de trabajo

Empieza por parseCategorySeconds en workers/NotifyWorker.kt:203-229 y por el NotifyWorkerExecutionTest que falla y se describe en el issue. Comprueba cómo gestiona la función la respuesta de androidQuery cuando contiene un objeto de error y, después, ejecuta la prueba con {"error":"x"} como respuesta falsa del backend. Se considera terminado cuando el error de la consulta se hace visible y el worker devuelve Result.retry() en lugar de informar que tuvo éxito.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Kotlin
Estrellas
291
Forks
73
Merge medio
4 d 5 h
PR fusionados (30 d)
27

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ActivityWatch/aw-android

Todos los issues de ActivityWatch/aw-android

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.