Skip to content

fix: handle JSONDecodeError in _handle_response to prevent crashes#85

Merged
gagebenne merged 3 commits intogagebenne:mainfrom
alexaustin007:main
Jul 26, 2025
Merged

fix: handle JSONDecodeError in _handle_response to prevent crashes#85
gagebenne merged 3 commits intogagebenne:mainfrom
alexaustin007:main

Conversation

@alexaustin007
Copy link
Copy Markdown
Contributor

  • Add ServerResponseError and ServerResponseErrorEnum for invalid JSON responses
  • Wrap response.json() in try/except to catch JSONDecodeError
  • Return ServerResponseError instead of crashing when API returns empty/malformed JSON
  • Fixes JSONDecodeError, raised exception not handled in _handle_response #62: erratic JSONDecodeError crashes during API polling

This prevents application crashes when Dexcom Share API returns empty or invalid JSON responses, allowing graceful error handling and retry logic

- Add ServerResponseError and ServerResponseErrorEnum for invalid JSON responses
- Wrap response.json() in try/except to catch JSONDecodeError
- Return ServerResponseError instead of crashing when API returns empty/malformed JSON
- Fixes gagebenne#62: erratic JSONDecodeError crashes during API polling

This prevents application crashes when Dexcom Share API returns empty or
invalid JSON responses, allowing graceful error handling and retry logic
@gagebenne
Copy link
Copy Markdown
Owner

gagebenne commented Jul 20, 2025

@alexaustin007 Nice. Thanks for the contribution!!! Feel free to give this another once over, otherwise I'll go ahead and merge it.

@alexaustin007
Copy link
Copy Markdown
Contributor Author

@gagebenne LGTM - please go ahead, happy to help!

@gagebenne gagebenne merged commit e5afd0b into gagebenne:main Jul 26, 2025
5 checks passed
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.

JSONDecodeError, raised exception not handled in _handle_response

2 participants