Skip to content

Commit 14f13ae

Browse files
committed
Fix overly broad INVALID_FIELD_VALUE mapping, redundant token refresh, and missing cache
- Narrow INVALID_FIELD_VALUE error mapping to require "Unable to determine action group setup" message substring, preventing unrelated validation errors from raising ActionGroupSetupNotFoundError - Remove redundant _refresh_token_if_expired() calls in fetch_events and unregister_event_listener since _post() already handles this - Add lru_cache to camelize_key for parity with _decamelize_key
1 parent a6482c1 commit 14f13ae

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

pyoverkiz/_case.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def decamelize(data: Any) -> Any:
3131
return recursive_key_map(data, _decamelize_key)
3232

3333

34+
@functools.lru_cache(maxsize=1024)
3435
def camelize_key(key: str) -> str:
3536
"""Convert a single snake_case key to camelCase."""
3637
parts = key.split("_")

pyoverkiz/client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ async def fetch_events(self) -> list[Event]:
458458
Per-session rate-limit : 1 calls per 1 SECONDS period for this particular
459459
operation (polling).
460460
"""
461-
await self._refresh_token_if_expired()
462461
response = await self._post(f"events/{self.event_listener_id}/fetch")
463462
return converter.structure(decamelize(response), list[Event])
464463

@@ -467,7 +466,6 @@ async def unregister_event_listener(self) -> None:
467466
468467
API response status is always 200, even on unknown listener ids.
469468
"""
470-
await self._refresh_token_if_expired()
471469
await self._post(f"events/{self.event_listener_id}/unregister")
472470
self.event_listener_id = None
473471

pyoverkiz/response_handler.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
_ERROR_CODE_MESSAGE_MAP: list[tuple[str, str | None, type[BaseOverkizError]]] = [
4747
# --- errorCode is the sole discriminator ---
4848
("DUPLICATE_FIELD_OR_VALUE", None, DuplicateActionOnDeviceError),
49-
("INVALID_FIELD_VALUE", None, ActionGroupSetupNotFoundError),
49+
(
50+
"INVALID_FIELD_VALUE",
51+
"Unable to determine action group setup",
52+
ActionGroupSetupNotFoundError,
53+
),
5054
("INVALID_API_CALL", None, NoSuchResourceError),
5155
("EXEC_QUEUE_FULL", None, ExecutionQueueFullError),
5256
("NO_SUCH_DEVICE", None, NoSuchDeviceError),

0 commit comments

Comments
 (0)