fix(): Fix Undefined Crash - #102
Open
Arielpetit wants to merge 1 commit into
Open
Conversation
Author
|
@Younesfdj @Mawsis Can you please review this ? |
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.
PR: Fix
FOUNDER_OVERALLUndefined CrashIssue
The card builder uses two separate lookup tables for founders:
FOUNDERS— visual metadata (art, accent, label)FOUNDER_OVERALL— forced overall ratingThe existing implementation checked
FOUNDERSto determine whether a user was a founder, but then unconditionally read fromFOUNDER_OVERALL:This assumes the two tables always remain in sync, but there was no protection against them diverging.
If a login exists in
FOUNDERSbut is missing fromFOUNDER_OVERALL:FOUNDERSlookup succeeds.FOUNDER_OVERALL[...]returnsundefined.overallbecomesundefined.pad2(undefined)producing"undefined"or arithmetic resulting inNaN).Additionally, founder overalls bypassed the
clamp(1, 99)safety check that every other card receives, allowing invalid values such as0or100to render unchanged.Fix
Replaced the single ternary with a guarded two-step lookup:
This change provides two safeguards:
FOUNDER_OVERALL, the code now falls back to the normal scoring calculation instead of producingoverall = undefined.Behavior Before vs. After
FOUNDERSbut missing fromFOUNDER_OVERALLoverall = undefined→ render crash0or1001–99Files Changed
lib/scoring/engine.tsFOUNDER_OVERALLlookup with a guarded lookup, added an explicit fallback to normal scoring, and clamped founder overalls to the1–99range.tests/engine.test.tsFOUNDER_OVERALL, and another verifies founder overalls are always clamped to the valid range.Verification
npm test→ 278 passed, 0 failures (22 test files)npm run lint→ 0 errorsnpm run build→ Compiled successfully with no TypeScript errors