Skip to content

Fix four bugs found during code audit#10

Merged
tempus2016 merged 1 commit intomainfrom
claude/analyze-test-coverage-LkM4P
Mar 24, 2026
Merged

Fix four bugs found during code audit#10
tempus2016 merged 1 commit intomainfrom
claude/analyze-test-coverage-LkM4P

Conversation

@tempus2016
Copy link
Copy Markdown
Owner

Bugs fixed

1. sensor.py — Crash on corrupted settings
float() and int() were called directly on user-configurable settings with no error handling. A corrupted value (e.g. someone typed letters instead of a number) would throw a ValueError and crash the sensor, making the whole integration unavailable. Added _safe_float() / _safe_int() helpers that fall back to sensible defaults.

2. sensor.py — Fragile double dict lookup
child_lookup.get(comp.child_id, None) and child_lookup[comp.child_id].name looked up the same key twice. Replaced with a clean single lookup.

3. coordinator.pyTypeError crash in recurrence availability check
is_chore_available_for_child() caught ValueError when parsing a stored date string, but not TypeError. If the stored value happened to be None or a non-string, slicing it with [:10] raises TypeError, which was unhandled and would crash the chore availability check. Now catches (ValueError, TypeError).

4. coordinator.py / storage.pyasync_reject_reward() bypassed storage API
Reward rejection was directly writing to storage._data["reward_claims"] instead of going through the storage layer. Added a proper remove_reward_claim() method to TaskMateStorage and updated the coordinator to use it.

Test plan

  • All 120 tests pass
  • CI is green

1. sensor.py: double dict lookup on child_lookup could produce unexpected
   results — replaced with a clean single lookup using `in` check.

2. sensor.py: float()/int() conversions on settings values had no error
   handling — a corrupted setting would crash the sensor and make the whole
   integration unavailable. Added _safe_float()/_safe_int() helpers with
   fallback defaults.

3. coordinator.py: is_chore_available_for_child() caught ValueError but not
   TypeError when slicing current_iso — if the stored value was not a string
   (e.g. None), [:10] raises TypeError which was unhandled and would crash
   the availability check. Now catches (ValueError, TypeError).

4. coordinator.py / storage.py: async_reject_reward() was directly writing
   to storage._data["reward_claims"] bypassing the storage API, making it
   fragile to internal storage changes. Added remove_reward_claim() to
   TaskMateStorage and updated the coordinator to use it.

https://claude.ai/code/session_01CkPmKWe5siThpfZ6GDpNQF
@tempus2016 tempus2016 merged commit 4ffb275 into main Mar 24, 2026
4 checks passed
@tempus2016 tempus2016 deleted the claude/analyze-test-coverage-LkM4P branch March 24, 2026 18:45
tempus2016 added a commit that referenced this pull request Mar 30, 2026
…kM4P

Fix four bugs found during code audit
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