Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

QUOTA_EXCEEDED is not mapped to TooManyRequestsError, so rate limiting arrives untyped

Aperta Adatta ai principianti
#2,263 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
api, backend

Direzione di ricerca

Inizia in response_handler.py, nelle tre mappe degli errori e in check_response, prestando particolare attenzione alla mappatura esistente di TooManyRequestsError intorno alla riga 60. Riproduci il caso FakeResp dell’issue, quindi verifica che una risposta QUOTA_EXCEEDED sollevi TooManyRequestsError invece del generico OverkizError. Il lavoro è concluso quando la risposta effettiva di limitazione della frequenza è tipizzata in modo coerente con il percorso di back-off previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🐛 The problem

The Overkiz cloud reports its polling quota with errorCode: QUOTA_EXCEEDED, which matches none of the three error maps in response_handler.py, so it falls through to the generic raise at the end of check_response:

pyoverkiz.exceptions.OverkizError: {'errorCode': 'QUOTA_EXCEEDED', 'error': 'Too many requests, try again later'}

TooManyRequestsError is only reachable for a different errorCode (response_handler.py:60):

("AUTHENTICATION_ERROR", "Too many requests", TooManyRequestsError),

So the one exception type that means "you are being rate limited" is never raised for the server's actual rate-limit response.

🔁 Reproduction

import asyncio
from pyoverkiz.response_handler import check_response
from pyoverkiz.exceptions import OverkizError, TooManyRequestsError

class FakeResp:
    status = 403
    url = "https://example/events/x/fetch"
    async def json(self, content_type=None):
        return {"errorCode": "QUOTA_EXCEEDED",
                "error": "Too many requests, try again later"}

async def main():
    try:
        await check_response(FakeResp())
    except TooManyRequestsError:
        print("typed")
    except OverkizError as err:
        print("untyped:", err)

asyncio.run(main())   # -> untyped: {'errorCode': 'QUOTA_EXCEEDED', ...}

Why none of the maps catch it:

  • _ERROR_CODE_MESSAGE_MAP (:47) — has no QUOTA_EXCEEDED entry
  • _MESSAGE_FALLBACK_MAP (:104) — has "Too many executions" and "Too many attempts with an invalid token", but not "Too many requests"
  • _ERROR_CODE_FALLBACK_MAP (:121) — only AUTHENTICATION_ERROR and RESOURCE_ACCESS_DENIED

📉 Why it matters

Callers cannot distinguish rate limiting from an unknown server error without string-matching the payload, so any back-off keyed on TooManyRequestsError silently never runs.

Measured on an Atlantic Cozytouch V2 hub (cloud API), eight commands issued in parallel to eight heaters, Home Assistant's overkiz integration:

observed
fetch_events rate during the burst 1.32 /s (documented limit: 1/s)
polling intervals under 1 s 5, shortest 0.23 s
QUOTA_EXCEEDED raised 1
commands that reached the hub 5 / 8

Because the error arrives untyped:

  • it surfaces as Unexpected error fetching device events data with a full traceback, rather than a handled rate-limit path
  • the coordinator keeps polling at the interval that hit the limit instead of slowing down
  • the failed update marks every entity unavailable, and Home Assistant then refuses the remaining service calls — Referenced entities ... are missing or not currently available — so three commands were silently dropped
  • worst state-delivery lag in that run was 28.97 s

✅ Suggested fix

Either map the code directly in _ERROR_CODE_MESSAGE_MAP:

("QUOTA_EXCEEDED", None, TooManyRequestsError),

…or, more robustly, add the message to _MESSAGE_FALLBACK_MAP so it matches whatever errorCode carries it:

("Too many requests", TooManyRequestsError),

The second also covers the existing AUTHENTICATION_ERROR variant, and any future code the cloud attaches to the same message.

🧾 Environment

  • pyoverkiz 2.1.0
  • Hub: Atlantic Cozytouch V2 (io://****-****-9776), cloud API — local API not available for this server
  • Seen on the events/{listener_id}/fetch endpoint, documented as "1 calls per 1 SECONDS period for this particular operation (polling)"

Happy to open a PR for whichever form you prefer.

Lingua principale
Python
Stelle
58
Fork
35
Merge medio
3g 15h
PR unite (30g)
20

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di iMicknl/python-overkiz-api

Tutte le issue di iMicknl/python-overkiz-api

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.