Skip to content

fix(omi-whoop-app): add request timeouts, null score guards, and type validation (#14278) - #14281

Merged
Git-on-my-level merged 4 commits into
BasedHardware:mainfrom
PINYOPATTANAWASANPORN:fix-whoop-hardening
Sep 17, 2026
Merged

Git-on-my-level merged 4 commits into
BasedHardware:mainfrom
PINYOPATTANAWASANPORN:fix-whoop-hardening

Conversation

@PINYOPATTANAWASANPORN

@PINYOPATTANAWASANPORN PINYOPATTANAWASANPORN commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary of Changes

  • Introduced WHOOP_REQUEST_TIMEOUT = 10 constant and applied it to all outgoing
    equests.get() and
    equests.post() calls across
    efresh_access_token(), whoop_api_request(), and the OAuth authorization code exchange.
  • Hardened ormat_recovery_score, ormat_strain_score, ormat_sleep, and ormat_workout against None, malformed dictionaries, and non-numeric metric values with graceful fallback responses.
  • Added defensive string casting before date slicing in ool_get_recovery, ool_get_strain, and ool_get_sleep.
  • Added automated unit test coverage in est_whoop_hardening.py covering null, malformed, and valid data paths.

Fixes #14278

Failure-Class: none

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @PINYOPATTANAWASANPORN — reviewed this against the head (89e3b88) and ran the tests locally. This is a solid, cohesive hardening pass; a few notes below.

Verified:

  • WHOOP_REQUEST_TIMEOUT = 10 is now applied to all three outbound Whoop calls — refresh_access_token(), whoop_api_request(), and the OAuth authorization-code exchange in whoop_callback(). I grepped the full head file: no un-timed requests.* call remains. This closes real hang exposure in a plugin that previously made blocking calls with no timeout.
  • The null/type guards in format_recovery_score, format_strain_score, format_sleep, and format_workout fix genuine crash paths. The old recovery.get("score", {}) pattern crashes when Whoop returns "score": null (a dict default only fires on a missing key, not on an explicit null) — the isinstance checks are the right fix.
  • str(... or "")[:10] date slicing in tool_get_recovery / tool_get_strain / tool_get_sleep correctly handles null created_at/start/end.
  • Ran the new test_whoop_hardening.py (24/24 pass) and the pre-existing test_get_workouts.py (4/4 pass) against the head — no regressions.

Minor behavior deltas worth knowing (non-blocking):

  • Metric lines now render when a value is literally 0 (is not None instead of truthiness) — arguably a fix (e.g. a 0-strain day now shows), just noting the display change.
  • Sleep total hours are clamped with max(0.0, total_sleep - total_awake), so negative totals can no longer display.

Both changed files are plugin-local Python with no dependency, workflow, or secrets changes. Leaving formal merge sign-off to a human maintainer; from a code-correctness standpoint this looks ready.

Reviewed as part of Omi's automated maintainer workflow on behalf of David. AI-generated feedback — please flag any errors.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution python labels Sep 17, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obvious plugin bugfix with tests; CI green on this head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(omi-whoop-app): add request timeouts, null score guards, and type validation

2 participants