fix(client): guard additionalCostChoices Choice branch against a short payload#5175
Open
jeffrey701 wants to merge 1 commit into
Open
fix(client): guard additionalCostChoices Choice branch against a short payload#5175jeffrey701 wants to merge 1 commit into
jeffrey701 wants to merge 1 commit into
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
93ab267 to
23aa004
Compare
…t payload The "Choice" additional-cost branch formats cost.data[0] and cost.data[1] directly. The type is a 2-tuple, but data is deserialized from the engine, so a malformed/short payload leaves cost.data[1] undefined. formatAbilityCost switches on cost.type, so passing undefined throws a TypeError and hard-crashes the cost-choice modal instead of degrading. Guard each option with a fallback label, mirroring the sibling Kicker branch's existing defense.
23aa004 to
5a30d6e
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.
Problem
additionalCostChoices(client/src/viewmodel/costLabel.ts) formats theChoicebranch by indexing straight into the cost tuple:datais typed[SerializedAbilityCost, SerializedAbilityCost], but it is deserialized from the engine. A malformed/short payload leavescost.data[1]undefined;formatAbilityCostswitches oncost.type, soundefined.typethrows aTypeErrorand hard-crashes the cost-choice modal instead of degrading. The siblingKickerbranch already guards exactly this (const label = first ? … : "kicker").Fix
Destructure and guard each option with a fallback label ("Pay" / "Decline").
Test
client/src/viewmodel/__tests__/costLabel.test.ts— a well-formed two-cost Choice still labels both options; a short payload no longer throws and falls back to "Decline".