Skip to content

fix(apple-health): take a percent from a fraction or an already-scaled client - #1000

Merged
MBombeck merged 1 commit into
mainfrom
fix/hk-percent-tolerance
Sep 18, 2026
Merged

MBombeck merged 1 commit into
mainfrom
fix/hk-percent-tolerance

Conversation

@MBombeck

Copy link
Copy Markdown
Owner

Oxygen saturation and body fat never reach the server from the iOS app: the app scales them by 100 before upload, the importer scales again, the plausibility guard rejects the row as out of range inside a 200, and the client treats that skip as final and advances its HealthKit anchor. The reading stays on the phone and is never retried. Reported with a full cross-repo trace in MBombeck/healthlog-iOS#7.

The contract says values travel raw and the server scales them, which is what the OpenAPI description publishes. One comment in prisma/schema.prisma said the opposite; that is the line the app was built against, and it is corrected here.

The five percent-shaped HealthKit identifiers now accept either spelling, so current App Store builds stop losing readings without waiting for an app release. The range guard still rejects an impossible value either way.

Note for review: waistCircumference uses the same x100 to convert metres to centimetres. A blanket change turned a 1.02 m waist into 1.02 cm, so a test now pins the tolerant converter to the percent class and to nothing else.

…d client

Shipped iOS builds multiply oxygen saturation and body fat by 100 before
upload. The importer scaled them again, so 0.97 was stored as 9700, the
plausibility guard rejected the row as out of range inside an HTTP 200,
and the client treats that skip as final and moves its HealthKit anchor
past the sample. Every reading of those two types was lost, silently, on
every install that syncs them.

The contract says values travel raw and the server scales, and that is
what the OpenAPI description publishes. One comment in the schema said
the opposite, that the client must multiply by 100 first, and that is
the line the app was built against. It is corrected here.

The five percent-shaped HealthKit identifiers now take either spelling:
a value above the fraction ceiling is already a percent and passes
through, anything at or below it is scaled. The domains do not overlap,
and the per-type range guard still rejects what is impossible either
way. Current app builds stop losing readings without an app release.

The tests pin both spellings, the range after conversion, and that the
tolerant converter covers the percent class and nothing else: waist
circumference uses the same factor to turn metres into centimetres, and
a blanket change made a 1.02 m waist into 1.02 cm.

Refs MBombeck/healthlog-iOS#7
@MBombeck
MBombeck merged commit 1fe90f3 into main Sep 18, 2026
24 checks passed
@MBombeck
MBombeck deleted the fix/hk-percent-tolerance branch September 18, 2026 14:59
@MBombeck MBombeck mentioned this pull request Sep 20, 2026
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.

1 participant