Skip to content

fix: raise SpaOfflineError when currentState is missing#125

Merged
arska merged 4 commits into
mainfrom
fix/currentstate-keyerror
May 5, 2026
Merged

fix: raise SpaOfflineError when currentState is missing#125
arska merged 4 commits into
mainfrom
fix/currentstate-keyerror

Conversation

@arska
Copy link
Copy Markdown
Owner

@arska arska commented May 5, 2026

Summary

  • Adds SpaOfflineError exception raised when the API response lacks currentState (typically means spa gateway is offline)
  • Previously this caused a cryptic KeyError: 'currentState' deep in property accessors — now it fails fast with a descriptive message in _get_info()
  • Exports SpaOfflineError from the package so consumers can catch it specifically

Context

Seeing ~500 KeyError: 'currentState' events per week in Sentry from a downstream consumer (controlmyspa-porssari). The ControlMySpa API sometimes returns spa data without currentState when the gateway is offline.

Test plan

  • New test verifies SpaOfflineError is raised when currentState key is absent
  • All existing tests pass unchanged

🤖 Generated with Claude Code

When the spa gateway is offline, the API returns spa data without a
'currentState' key, causing KeyError in all property accessors. This
adds a dedicated SpaOfflineError exception raised early in _get_info()
with a clear message, so callers can handle the offline case gracefully.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
arska and others added 3 commits May 5, 2026 10:35
The spa gateway being temporarily offline is often transient. Retrying
the data fetch (without re-authenticating) gives it a chance to recover
before erroring out.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@arska arska self-assigned this May 5, 2026
@arska arska merged commit f7a1c85 into main May 5, 2026
16 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.

1 participant