v0.8.2 — Three-layer measurement input validation
Korean infant/child reference data integration for Home Assistant.
Install via HACS → Custom repositories →https://github.com/redchupa/kr_baby_kit(Category: Integration).
Medical data integrity patch. Until v0.8.1 the integration accepted anything coerce-able to float() on measurement inputs — including NaN, Infinity, negative numbers, and stratospheric out-of-range values — and the LMS / BMI / weight-for-length math downstream then either produced nonsense percentiles or crashed deep inside the calculation. v0.8.2 closes that.
🛡️ Three layers of validation
| Layer | What it does | Surfaces error as |
|---|---|---|
record_measurement service |
_bounded_float() schema rejects type / NaN / Inf / range up front |
voluptuous Invalid → service-call response |
Dashboard number entity |
HA's native min/max/step constrain the slider (unchanged behaviour) |
UI-level clamping |
storage.async_append_measurement |
Re-validates regardless of caller | ValueError with Korean message |
The middle layer was already fine; the first and third are new in v0.8.2.
❌ Inputs now rejected (Korean error messages)
| Bad input | Message |
|---|---|
None / 빈 값 |
키 값이 비어 있습니다. |
"abc", "!!", "1,2", "" |
키 값을 숫자로 읽지 못했습니다: 'abc' |
True / False |
키 값은 숫자여야 합니다 (참/거짓 X). |
NaN |
몸무게 값이 NaN 입니다. |
±Infinity |
몸무게 값이 무한대입니다. |
height=-5 / weight=150 / head=10 등 범위 밖 |
키 값이 허용 범위를 벗어났습니다: -5.0 cm (허용: 30.0–200.0 cm). |
date: "not-a-date" |
측정일 형식이 올바르지 않습니다 (YYYY-MM-DD): 'not-a-date' |
📏 Plausibility ranges
Wider than the KDCA 0–228 month chart (45–180 cm height, 3–80 kg weight, 33–58 cm head) so a slightly off entry still stores; clearly-mistyped values are caught up front.
| 항목 | 최소 | 최대 |
|---|---|---|
| 키 | 30.0 cm | 200.0 cm |
| 몸무게 | 1.0 kg | 100.0 kg |
| 머리둘레 | 25.0 cm | 65.0 cm |
✅ Tests
- +33 unit tests in
tests/test_validation.pycovering every rejection class. - +4 storage-layer regression tests proving out-of-range / negative / non-numeric / NaN values are rejected at the persistence boundary, not only at the schema.
- Total: 109 passed (
pytest -q --ignore=tests/integration).
Upgrade notes
unique_id, sensor values, and on-disk records all unchanged.- Existing valid measurements continue to work without re-entry.
- Service-call payloads that previously accidentally passed (e.g.
weight: 0) now fail loudly with a Korean message — fix the payload and resubmit.
Full CHANGELOG: CHANGELOG.md