Skip to content

fix: reject oversized CHAT_RATE_* values at boot instead of at request time (fixes #744) - #877

Open
RobGenins wants to merge 4 commits into
flop-labs:mainfrom
RobGenins:fix/rate-overflow-v2-clean
Open

RobGenins wants to merge 4 commits into
flop-labs:mainfrom
RobGenins:fix/rate-overflow-v2-clean

Conversation

@RobGenins

Copy link
Copy Markdown

Replaces #863 with a clean rebase on v0.14.0.

Fixes: #744

Rejects oversized CHAT_RATE_* env values at config import time (via float() conversion check), instead of crashing at request time with OverflowError.

RobGenins and others added 4 commits September 19, 2026 14:03
…t time

The three rate-limit env vars were parsed with int(), which accepts arbitrary precision. limit.py:take() converts to float at request time, so a 400-digit value caused OverflowError on every route.

Fix: attempt float(v) conversion at boot and catch OverflowError — rejects only values that would actually overflow at runtime, without imposing an arbitrary ceiling. A float-safe value like 10,000,001 is accepted; a 400-digit value is rejected.

Based on yukkie3276's review: reject the actual representation boundary rather than a hard 10M cap.
…ection

Adds boot-level tests for all three rate-limit environment variables:
- Overflowing values (400-digit) assert boot refusal
- Large float-representable values (10,000,001) assert successful boot

Addresses flop-labs#744 review feedback: the fix existed but lacked executable
regression coverage.
Moves the max(1, v) floor before the float(v) OverflowError guard so that
oversized negative values (e.g. a 400-digit negative) are floored to 1 and
then pass representability without issue — matching the pre-PR contract
where zero/negative values were silently floored.

Addresses review feedback on PR flop-labs#820.
Asserts that a 400-digit negative value floors to 1 and boots cleanly,
since max(1, v) is now applied before the float(v) representability check.

Addresses review feedback on PR flop-labs#820.
@github-actions

Copy link
Copy Markdown

Open pull requests citing the same issues:

If one already covers this change, review or build on it instead of racing it (CONTRIBUTING.md "Overlapping work").

@WIZARDspace

Copy link
Copy Markdown
Contributor

This is #863's four commits, patch-identical (git range-diff: all =), rebased onto main@e4c4f73. There is no v0.14.0 tag; the latest is v0.13.0.

So my comparison on #863 still applies: #863 (comment). In particular, ruff format --check src/config.py still fails on this head at the same three spots (:46, :57, :71), and ruff format fixes all three. lint + tests + image hasn't run here either: CI and pr-guards are action_required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Oversized CHAT_RATE_* values boot successfully, then limited requests return 500

2 participants