Fix stale timer after loop close in BoundedWarning and validate BeginRateLimiter.configure
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start with server/orcaster_server/auth/rate_limit.py, especially BoundedWarning.hit and BeginRateLimiter.configure, then read the related cases in server/tests/auth/test_begin_rate_limit.py. Add coverage for warnings whose timer belongs to a closed loop, including KeyedBoundedWarning, and for limiter validation. Done means the pending warning is emitted on the new loop, invalid values raise ValueError, zero per-client rate remains disabled, and the Unreleased changelog is updated.
Written by the indexing model from the issue text.
Description
Problem
Two small defects in server/orcaster_server/auth/rate_limit.py.
-
A timer that belongs to a closed event loop is never replaced.
BoundedWarning.hitschedules the trailing flush only when_flush_handle is None(server/orcaster_server/auth/rate_limit.py:314). If the loop that owns the handle closes before the timer runs, the pending callback is discarded and the handle stays set. No new timer is scheduled, so the trailing count stays pending until a later request arrives after the window.KeyedBoundedWarningreusesBoundedWarning, so it has the same defect.
A server process normally has one loop for its whole life, so mostly tests, a restarted loop in the same process and shutdown are affected. -
BeginRateLimiter.configuredoes not validate its arguments (server/orcaster_server/auth/rate_limit.py:196). For exampleBeginRateLimiter(30, 0)builds a limiter with a burst of 0 that rejects every request.AuthConfigalready validates these values (server/tests/auth/test_begin_rate_limit.py:830), but direct construction does not.
The BoundedWarning docstring says "at most one per interval seconds" (server/orcaster_server/auth/rate_limit.py:252). The code emits a leading line and a trailing line per window (server/tests/auth/test_begin_rate_limit.py:278), so the docstring should say two.
Steps to reproduce
Closed loop:
- On loop A, call
hit()twice on aBoundedWarningwith a long interval. The first hit emits, the second leaves a pending count and a timer. - Close loop A before the timer runs.
- On loop B, call
hit()inside the window, then run loop B past the end of the window. - Only the first line is logged and the count is still pending.
Validation: BeginRateLimiter(30, 0).check("client") returns a wait time on the first call.
Proposed change
- Store the loop together with the handle. In
hit, schedule a new timer when the handle is missing, cancelled, or its loop is closed (loop.is_closed()). - State in the
BoundedWarningdocstring that it must be used only from the event-loop thread, and that it emits at most two lines per window (leading and trailing). - Validate in
configurethe same rules asAuthConfig: per-client rate>= 0and burst>= 1, and the same for the per-network pair. RaiseValueError. Keepper_minute == 0meaning "level disabled".
Acceptance criteria
- A test shows that a
BoundedWarningwhose timer belongs to a closed loop emits its pending count after the window closes in a new loop. - The same test covers
KeyedBoundedWarningwith two successive loops. -
BeginRateLimiter(30, 0)andBeginRateLimiter(-1, 10)raiseValueError(test), andBeginRateLimiter(0, 1)still disables the per-client level. - Existing deployments keep working without config changes: default settings and values accepted by
AuthConfigare still accepted. - CHANGELOG entry under Unreleased.
Open questions
- Should the 429 log line carry a truncated or hashed client key? Today the message has no client value (
server/orcaster_server/auth/rate_limit.py:259), which also means an operator cannot tell who sends a flood from this log alone. The alternative is to keep the log and document where to find the source (the reverse proxy log). register/beginuses the same limiter aslogin/begin(server/orcaster_server/auth/router.py:142,server/orcaster_server/auth/router.py:306). Aregister/beginrequest that returns 410 (bad invitation) or 400 (invalid display name) creates nothing but still spends a token. Should it be refunded, or only documented? A refund lets a probe run without cost.
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AInvirion/orcaster
-
enhancement P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
enhancement good first issue P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug P2 server
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
bug P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
enhancement P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
All issues in AInvirion/orcaster
Similar issues
-
[Resource]: SpaicelyOpenresource-submission validation-passed
Difficulty 1/5 Under an hour Newbie friendliness 68/100
hesreallyhim/awesome-claude-code#3875 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
bvis/aegis-hass#725 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.xPossibly taken @NimaVaziri claimed this today. OpenPytorch
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/TensorRT-LLM#23406 ·
Maintainers usually reply within 1 day