🐛 Raise ComwattAPIError for non-credential authent failures #46

Merged
mat merged 1 commit from authent-error-statuses into main 2026-07-05 10:51:31 +00:00
Owner

Problem

_post_authent raises ComwattAuthError for any non-200 on POST /v1/authent — including 5xx during a Comwatt outage — and for the HTTP-200-but-no-cwt_session-cookie anomaly. Consumers (e.g. the Home Assistant integration) map ComwattAuthError to invalid credentials, so an outage gets misreported as a bad password.

Change

On POST /v1/authent:

Response Before After
401 / 403 ComwattAuthError ComwattAuthError
other non-200 (e.g. 5xx) ComwattAuthError ComwattAPIError
200 without cwt_session cookie ComwattAuthError ComwattAPIError

_api_error() (regular API calls) is intentionally untouched. Docstrings + README updated accordingly.

Tests

  • test_authenticate_missing_cookie now expects ComwattAPIError
  • New: test_authenticate_error_403 (→ ComwattAuthError, .status_code == 403)
  • New: test_authenticate_server_error_is_not_auth_error (503 → ComwattAPIError)
  • Full suite: 94/94, mypy clean

Prepares comwatt-client 0.3.4, needed by the Home Assistant integration to map ComwattAuthError → reauth flow safely.

## Problem `_post_authent` raises `ComwattAuthError` for **any** non-200 on `POST /v1/authent` — including 5xx during a Comwatt outage — and for the HTTP-200-but-no-`cwt_session`-cookie anomaly. Consumers (e.g. the Home Assistant integration) map `ComwattAuthError` to *invalid credentials*, so an outage gets misreported as a bad password. ## Change On `POST /v1/authent`: | Response | Before | After | |---|---|---| | 401 / 403 | `ComwattAuthError` | `ComwattAuthError` | | other non-200 (e.g. 5xx) | `ComwattAuthError` | `ComwattAPIError` | | 200 without `cwt_session` cookie | `ComwattAuthError` | `ComwattAPIError` | `_api_error()` (regular API calls) is intentionally untouched. Docstrings + README updated accordingly. ## Tests - `test_authenticate_missing_cookie` now expects `ComwattAPIError` - New: `test_authenticate_error_403` (→ `ComwattAuthError`, `.status_code == 403`) - New: `test_authenticate_server_error_is_not_auth_error` (503 → `ComwattAPIError`) - Full suite: 94/94, mypy clean Prepares comwatt-client **0.3.4**, needed by the Home Assistant integration to map `ComwattAuthError` → reauth flow safely.
🐛 Raise ComwattAPIError for non-credential authent failures
All checks were successful
Tests / forgejo-pytest (push) Successful in 42s
Tests / forgejo-pytest (pull_request) Successful in 42s
ebe1581e49
mat changed title from WIP: 🐛 Raise ComwattAPIError for non-credential authent failures to 🐛 Raise ComwattAPIError for non-credential authent failures 2026-07-05 10:51:27 +00:00
mat merged commit faeabaff2e into main 2026-07-05 10:51:31 +00:00
mat deleted branch authent-error-statuses 2026-07-05 10:51:31 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mat/python-comwatt-client!46
No description provided.