Skip to content

fix(settings): store falsy values instead of deleting the key - #230

Merged
ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:fix/settings-keep-falsy-values
Nov 24, 2026
Merged

ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:fix/settings-keep-falsy-values

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Settings.set removed the key for any falsy value. POST /api/0/settings/<key> with [], {}, false, 0 or "" returned 200 and echoed the value, but nothing was stored, and GET then returned null.

aw-webui falls back to its defaults when a key is missing. In practice:

  • deleting every category (classes: []) restores the default categories on the next load
  • deleting every alert goal brings the sample goals back (Alerts.vue seeds them when nothing is stored)
  • unchecking a boolean that defaults to on (for example devmode in dev builds) doesn't persist

Only null deletes now. aw-server-rust's setting_set already stores any JSON value verbatim.

Test: test_falsy_value_is_stored_not_deleted covers [], {}, false, 0 and "" through the REST endpoint. It failed on master for all five values and passes with the fix. The old test_falsy_value_deletes_key_on_success enshrined the bug for "", so it now asserts deletion via None only. The full suite passes: 317 passed (test_client.py excluded, since it needs a live server).

Settings.set dropped the key for any falsy value, so POSTing [], {}, false,
0 or "" returned 200 but left nothing stored. aw-webui then fell back to
its defaults on reload: deleting every category or alert goal brought the
defaults back, and unchecking a default-on toggle did not persist.

Only null deletes now, matching aw-server-rust, which stores any JSON
value verbatim.

Git-Session-Id: 13b9747e-b0b2-4f45-87b6-509c3b6fef7f
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Review guide (auto-posted)

Structured warm-up for reviewers — what changed, what to run, where to look.

Key files

  • tests/test_settings.py (+23/-2, Δ25)
  • aw_server/settings.py (+3/-1, Δ4)

Suggested verification

  • uv run pytest tests/test_settings.py -q
  • make typecheck

Known risks / watch points

  • No automatic high-risk tags; use file list + diff for judgment.

Suggested review focus

  • Confirm behavior matches the PR description acceptance criteria.
  • Skim the largest diffs first (listed above).
  • If CI is green, spot-check the highest-risk paths called out here.

Generated by scripts/github/pr-warmup-review-guide.py for #230.

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] Safe to merge; no blocking issues found.

Summary

Settings now keep empty lists, empty objects, false, 0, and empty strings. Only null removes a key.

  • Settings keep empty and false-like values instead of deleting them.

Reviews (2) · Last reviewed commit: "test(settings): check the stored type, s..." · Reviewed by Greptile

Comment thread tests/test_settings.py Resolved
Git-Session-Id: 13b9747e-b0b2-4f45-87b6-509c3b6fef7f
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@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 eb77ad1 into ActivityWatch:master Nov 24, 2026
9 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