Skip to content

get_training_status crashes with NoneType when heatAltitudeAcclimationDTO is null #172

Description

@phdelodder

Bug

get_training_status raises 'NoneType' object has no attribute 'get' on every call,
regardless of date. Completely broken for users where heatAltitudeAcclimationDTO
is not populated (no heat/altitude training context).

Reproducer

get_training_status("2026-06-24")  # date with actual ride
# → Error retrieving training status data: 'NoneType' object has no attribute 'get'

Root cause (confirmed via raw API dump)

The endpoint /metrics-service/metrics/trainingstatus/aggregated/{date} returns:

{
  "userId": 95143166,
  "mostRecentVO2Max": { "cycling": { "vo2MaxPreciseValue": 52.4 }, ... },
  "mostRecentTrainingLoadBalance": { ... },
  "mostRecentTrainingStatus": { ... },
  "heatAltitudeAcclimationDTO": null
}

heatAltitudeAcclimationDTO is always null for this user (Edge 830 cyclist,
no heat/altitude training). The MCP wrapper calls .get() on it without a null-check.
On days without a recent activity, all four sub-objects are null, causing the crash
on mostRecentVO2Max instead.

Fix

acclimation = data.get("heatAltitudeAcclimationDTO")
heat_pct = acclimation.get("heatAcclimationPercentage") if acclimation else None

Same pattern for all four sub-objects. Identical to how get_training_readiness
handles empty responses.

Device

Garmin Edge 830 + vívoactive 4. Heat/altitude acclimation not applicable → field
is consistently null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions