From e5b9606bb85b2560d92e6c565133875288f9f0ed Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Mon, 20 Jul 2026 16:27:36 -0400 Subject: [PATCH] fix(wellness): reject unrecognized bulk fields instead of silently dropping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update_wellness_bulk kept only recognized snake_case keys and discarded the rest (e.g. API-style camelCase like restingHR) while reporting success — silent data loss across up to 92 days. Entries with unknown fields now reject the whole batch with a message naming the bad and valid field names. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01NGzHtDvJur9U7ysgRKRUTN --- tests/test_wellness.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_wellness.py b/tests/test_wellness.py index 47abdbd..87415cd 100644 --- a/tests/test_wellness.py +++ b/tests/test_wellness.py @@ -215,6 +215,20 @@ def test_update_wellness_bulk_too_many(monkeypatch): assert calls == [] +def test_update_wellness_bulk_rejects_unknown_keys(monkeypatch): + # camelCase/API-style names must be rejected, not silently dropped: the value + # the caller asked to record would otherwise be lost behind a success message. + calls = _patch_request(monkeypatch, [{}]) + out = asyncio.run( + wellness.update_wellness_bulk( + [{"date": "2026-07-18", "weight": 80, "restingHR": 50}] + ) + ) + assert "unrecognized field(s): restingHR" in out + assert "resting_hr" in out # the error names the valid fields + assert calls == [] # whole batch rejected, nothing written + + def test_update_wellness_bulk_error(monkeypatch): _patch_request(monkeypatch, {"error": True, "message": "boom"}) out = asyncio.run(wellness.update_wellness_bulk([{"date": "2026-07-18", "weight": 80}]))