Skip to content

fix(android): return an error object from getBuckets instead of panicking - #680

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/android-getbuckets-no-unwrap
Sep 14, 2026
Merged

ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/android-getbuckets-no-unwrap

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Follow-up from #679 / ActivityWatch/aw-android#261.

Java_…_RustInterface_getBuckets was the only JNI entry point that still unwrap()ed the datastore result. When the worker is gone (it panicked, for example because the database could not be opened), get_buckets() returns SendError/RecvError and the unwrap panicked across the JNI boundary on the calling thread. Seen in the emulator while reproducing #261:

log_panics: thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: InternalError("Failed to send request, datastore worker is gone: SendError")': aw-server/src/android/mod.rs:198
   8: Java_net_activitywatch_android_RustInterface_getBuckets

Now returns create_error_object like the other entry points. The Kotlin callers (createBucketHelper, EventParsingWorker, WatcherAndroidBucketMigration.legacyBucketIds) already tolerate a non-bucket JSON object. Not needed for v0.14.1; it turns a crash in an already-broken state into a logged error.

…king

If the datastore worker is gone (it panicked, e.g. the database could not
be opened), get_buckets() fails with SendError/RecvError and the unwrap
here panicked across the JNI boundary on the calling thread — usually the
main thread. Observed while reproducing ActivityWatch/aw-android#261.
Every other JNI entry point already returns create_error_object; the
Kotlin callers of getBuckets tolerate a non-bucket JSON object.
@greptile-apps

greptile-apps Bot commented Sep 14, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge and removes the identified datastore-error panic without changing successful responses.

Summary

  • Returns the established {"error": ...} JSON object when the datastore worker cannot service the request.
  • Preserves the existing bucket-map JSON response on success.
  • Aligns getBuckets error handling with the other Android JNI entry points.

Reviews (1) · Last reviewed commit: "fix(android): return an error object fro..."

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Self-merge not eligible here (cross-repo / policy gate). Waiting for human review or merge.

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.14%. Comparing base (656f3c9) to head (aadace8).
⚠️ Report is 106 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #680      +/-   ##
==========================================
+ Coverage   70.81%   80.14%   +9.32%     
==========================================
  Files          51       67      +16     
  Lines        2916     6059    +3143     
==========================================
+ Hits         2065     4856    +2791     
- Misses        851     1203     +352     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

@ErikBjare
ErikBjare merged commit 3b7ac33 into ActivityWatch:master Sep 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants