Skip to content

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

Closed

Description

@PINYOPATTANAWASANPORN

Problem Description

In plugins/omi-whoop-app/main.py, several edge cases and reliability risks can lead to unhandled exceptions and service degradation:

  1. Unbounded Network Requests: Calls to
    equests.get() and
    equests.post() in
    efresh_access_token(), whoop_api_request(), and the OAuth callback handler lack explicit HTTP timeouts. Under upstream Whoop API degradation or network partitioning, workers can hang indefinitely.
  2. Crash on Null or Missing Scores: Formatters ( ormat_recovery_score, ormat_strain_score, ormat_sleep, and ormat_workout) assume that the nested score object and its numeric metrics are always non-null dicts. When Whoop returns None or an empty dictionary (e.g. pending calculation), formatting throws AttributeError or TypeError.
  3. Unsafe String Slicing in Chat Tools: ool_get_recovery, ool_get_strain, and ool_get_sleep perform direct slices ([:10]) on date fields assuming string presence, raising TypeError if date fields are None.
  4. Missing Bounds Validation: Query parameters days and max_results in ool_get_workouts lack defensive integer casting and clamping against malformed input.

Proposed Solution

  • Introduce a centralized WHOOP_REQUEST_TIMEOUT = 10 constant and apply it across all outgoing network requests.
  • Add defensive type checks and fallback returns across all score formatters ( ormat_recovery_score, ormat_strain_score, ormat_sleep, ormat_workout).
  • Safely cast and slice date fields in chat tool endpoints.
  • Clamp and validate integer parameters in ool_get_workouts.
  • Add hermetic unit test coverage ( est_whoop_hardening.py) validating all edge cases without requiring network access or external credentials.

Proposed bounty:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions