fix(settings): stop normalizeOpenItemCap's cap leaking into unrelated fields - #3994
Merged
Merged
Conversation
… fields normalizeOpenItemCap gained a 100-row clamp for contributorOpenPrCap/ contributorOpenIssueCap, but three unrelated callers reused it purely for its "positive integer or null" validation and silently inherited the same 100 ceiling: requireFreshRebaseWindowMinutes and accountAgeThresholdDays (latent -- no existing test exercised a value above 100), and normalizeModerationDecayDays, which was double-clamped down from its own intended 3650-day ceiling (caught by 3 already-failing tests in moderation-config-db.test.ts). Extracts the shared validation into normalizePositiveIntOrNull with no cap, and has normalizeOpenItemCap and normalizeModerationDecayDays each apply their own, unrelated ceiling on top of it.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
❌ 1 Tests Failed:
View the full list of 1 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
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
normalizeOpenItemCaptoMAX_CONTRIBUTOR_OPEN_ITEM_CAP(100) forcontributorOpenPrCap/contributorOpenIssueCap, since live enforcement only ever samples a fixed 100-row budget.normalizeModerationDecayDays(violation-decay days, intended ceilingMAX_MODERATION_VIOLATION_DECAY_DAYS = 3650) — double-clamped down to 100 first, so its own ceiling was never reachable. Caught by 3 already-failing assertions intest/unit/moderation-config-db.test.ts(e.g.expected 100 to be 3650).requireFreshRebaseWindowMinutesandaccountAgeThresholdDays— silently capped at 100 (minutes / days respectively) with no existing test exercising a value above 100, so this was live but latent.normalizePositiveIntOrNull(no cap).normalizeOpenItemCapandnormalizeModerationDecayDayseach apply their own, unrelated ceiling on top of it; the other two fields use the uncapped helper directly.Scope
src/db/repositories.ts(the shared helper + its 5 call sites) andtest/unit/data-spine.test.ts(new regression coverage for the 2 latent fields).Validation
npx tsc --noEmit— clean.npx vitest run test/unit/data-spine.test.ts test/unit/moderation-config-db.test.ts— 35/35 pass (the 3 previously-failing moderation assertions now pass without being touched).src/db/repositories.ts: 100%.Safety
site//CNAME/lovablechanges.