[client] WeatherProxy.forecast docstring claims ComwattAuthError is never raised — a proxy 401 maps to it #183

Closed
opened 2026-10-27 11:31:55 +00:00 by mat · 0 comments
Owner

The WeatherProxy.forecast docstring (_weather.py:59-60) says:

This endpoint needs no authentication, so ComwattAuthError is never raised here.

That claim is wrong: _request funnels every non-200 into _api_error (_core.py:46-47), where any 401 maps to ComwattAuthError. A 401 from the proxy (upstream OpenWeatherMap auth issue, misconfigured gateway route) would surface as ComwattAuthError — misleading for an unauthenticated call.

Two options:

  • Fix the docstring (minimal, honest): document that a proxy 401 currently surfaces as ComwattAuthError via the shared error mapping;
  • Special-case unauthenticated absolute URLs so 401 → ComwattAPIError there: semantically cleaner but adds URL-based branching to _api_error — probably not worth it.

Recommend the docstring fix.

Done when: docstring matches actual behavior, and a test pins it (mock 401 → pytest.raises(ComwattAuthError)).

The `WeatherProxy.forecast` docstring (`_weather.py:59-60`) says: > This endpoint needs no authentication, so `ComwattAuthError` is never raised here. That claim is wrong: `_request` funnels every non-200 into `_api_error` (`_core.py:46-47`), where any 401 maps to `ComwattAuthError`. A 401 from the proxy (upstream OpenWeatherMap auth issue, misconfigured gateway route) would surface as `ComwattAuthError` — misleading for an unauthenticated call. **Two options:** - **Fix the docstring** (minimal, honest): document that a proxy 401 currently surfaces as `ComwattAuthError` via the shared error mapping; - **Special-case unauthenticated absolute URLs** so 401 → `ComwattAPIError` there: semantically cleaner but adds URL-based branching to `_api_error` — probably not worth it. Recommend the docstring fix. **Done when:** docstring matches actual behavior, and a test pins it (mock 401 → `pytest.raises(ComwattAuthError)`).
mat closed this issue 2026-10-27 14:36:31 +00:00
Sign in to join this conversation.
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#183
No description provided.