Skip to content

Commit 2535fe6

Browse files
nikolay-eclaude
andcommitted
Add comprehensive schema debugging for all Garmin data types
Now all data extraction functions have detailed logging: - Sleep: API response + DTO keys - HRV: API response + source format detection + keys - Heart Rate: API response + data keys - Stress: API response + data keys - Weight: Already had comprehensive debugging This will help identify schema issues across all data types, not just weight. When sync runs, we'll see exactly what Garmin API returns for each data type. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b7d6874 commit 2535fe6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pull_garmin_data.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,16 @@ def extract_sleep_data(
152152
"""Extract sleep data for a specific date and user using Pydantic validation."""
153153
try:
154154
raw_sleep_data = api.get_sleep_data(date_str)
155+
logger.info(f"Sleep API response for {date_str}: {raw_sleep_data}")
155156
if not raw_sleep_data:
157+
logger.info(f"No sleep data found for {date_str}")
156158
return None
157159

158160
# Extract the actual sleep data from the response
159161
sleep_dto = raw_sleep_data.get("dailySleepDTO", raw_sleep_data)
162+
logger.info(
163+
f"Sleep DTO keys for {date_str}: {list(sleep_dto.keys()) if isinstance(sleep_dto, dict) else type(sleep_dto)}"
164+
)
160165

161166
# Use Pydantic for robust parsing
162167
parsed_sleep = GarminSleepData.from_garmin_response(sleep_dto)
@@ -186,15 +191,23 @@ def extract_hrv_data(
186191
"""Extract HRV data for a specific date and user using Pydantic validation."""
187192
try:
188193
raw_hrv_data = api.get_hrv_data(date_str)
194+
logger.info(f"HRV API response for {date_str}: {raw_hrv_data}")
189195
if not raw_hrv_data:
196+
logger.info(f"No HRV data found for {date_str}")
190197
return None
191198

192199
# Handle different response formats
193200
hrv_source = raw_hrv_data
194201
if "hrvStatusSummary" in raw_hrv_data:
195202
hrv_source = raw_hrv_data["hrvStatusSummary"]
203+
logger.info(f"Using hrvStatusSummary for {date_str}")
196204
elif isinstance(raw_hrv_data, list) and raw_hrv_data:
197205
hrv_source = raw_hrv_data[0]
206+
logger.info(f"Using list[0] for HRV {date_str}")
207+
208+
logger.info(
209+
f"HRV source keys for {date_str}: {list(hrv_source.keys()) if isinstance(hrv_source, dict) else type(hrv_source)}"
210+
)
198211

199212
# Use Pydantic for robust parsing
200213
parsed_hrv = GarminHRVData.from_garmin_response(hrv_source)
@@ -391,9 +404,15 @@ def extract_heart_rate_data(
391404
# The get_heart_rates method might need the username
392405
# Try to get the heart rate data
393406
hr_data = api.get_heart_rates(date_str)
407+
logger.info(f"Heart Rate API response for {date_str}: {hr_data}")
394408
if not hr_data:
409+
logger.info(f"No heart rate data found for {date_str}")
395410
return None
396411

412+
logger.info(
413+
f"Heart Rate data keys for {date_str}: {list(hr_data.keys()) if isinstance(hr_data, dict) else type(hr_data)}"
414+
)
415+
397416
return HeartRate(
398417
user_id=user_id,
399418
date=target_date,
@@ -413,9 +432,15 @@ def extract_stress_data(
413432
"""Extract stress data for a specific date and user using Pydantic validation."""
414433
try:
415434
raw_stress_data = api.get_stress_data(date_str)
435+
logger.info(f"Stress API response for {date_str}: {raw_stress_data}")
416436
if not raw_stress_data:
437+
logger.info(f"No stress data found for {date_str}")
417438
return None
418439

440+
logger.info(
441+
f"Stress data keys for {date_str}: {list(raw_stress_data.keys()) if isinstance(raw_stress_data, dict) else type(raw_stress_data)}"
442+
)
443+
419444
# Use Pydantic for robust parsing
420445
parsed_stress = GarminStressData.from_garmin_response(raw_stress_data)
421446
if not parsed_stress:

0 commit comments

Comments
 (0)