fix(db): ignore non-finite rate_limited_until writes, preserve null clear - #12788
Open
maxmad64bis wants to merge 1 commit into
Open
fix(db): ignore non-finite rate_limited_until writes, preserve null clear#12788maxmad64bis wants to merge 1 commit into
maxmad64bis wants to merge 1 commit into
Conversation
maxmad64bis
force-pushed
the
fix/ratelimit-write-guard
branch
from
September 5, 2026 10:08
7aca7a8 to
d86ca05
Compare
maxmad64bis
force-pushed
the
fix/ratelimit-write-guard
branch
from
September 5, 2026 10:19
d86ca05 to
324d36f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rate-limit cooldowns are timestamps in the database, and until now any value got written — including ones that make no sense, like
NaN, or ones already in the past. A stale write could leave a connection looking locked (or unlocked) at the wrong time. Now only future timestamps are stored; anything expired or invalid is quietly skipped, and clearing a cooldown works exactly as before.Related Issues
Validation
npm run lintTests Added Or Updated
tests/unit/db-rate-limit-guard.test.ts(new) — 6 cases:NaNignored, ±Infinityignored, past/0ignored, future writes through,nullclear preserved, expired write doesn't overwrite a live row (6/6 pass; 3 fail before the guard as designed)tests/unitthat callssetConnectionRateLimitUntil—db-providers-crud,db-providers-split,antigravity-429-quota-cooldown,persist-429-cooldown-account-fallback,cooldown-epoch-string-3954,mark-account-unavailable-numeric-epoch-guard(82/82 pass)Coverage Notes
src/lib/db/providers/rateLimit.ts(one fused guard + comment at the head ofsetConnectionRateLimitUntil; readers,markConnectionRateLimitedUntil, andclearConnectionRateLimituntouched). Covered by the new test file; no new branches beyond the guard itself.Reviewer Notes
nullviaclearConnectionRateLimit. If any caller relied on writing the past to "unlock" a row, that pattern now needs an explicit clear (no such caller found in the test suites above).