Validate card metadata types at parse time #516
Labels
No labels
blocked
duplicate
needs
approval
needs
criteria
needs
estimate
needs
tests
question
step
doing
step
review
step
testing
step
todo
step
uat
type
admin
type
alert
type
bug
type
change
type
defect
type
epic
type
idea
type
incident
type
investigation
type
spike
type
story
wontfix
No project
No assignees
1 participant
Notifications
Total time spent: 20 minutes 1 second
Due date
Vylpes
20 minutes 1 second
No due date set.
Blocks
#517 Finish repo-wide strict equality sweep and enable eqeqeq
External/card-drop
Reference
External/card-drop#516
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #487 (2026 Code Clean Up). Spun out of the review note on PR #515.
Why
Card metadata is
JSON.parsed with no schema/type validation. Fields such astypeare declared numeric (CardRarity) in TypeScript, but a metadata file can still contain a string, e.g."type": "1".Under loose equality (
==) that value matched numeric1. After the strict-equality sweep in #515 (===), the same card would silently disappear from:GetUnclaimedCardsHelper)/inventorytype filters (InventoryHelper)/statsrarity countsStrict equality is the right long-term behaviour; the real fix is to reject or coerce bad metadata when it is loaded, not to keep
==.docs/cards.md(PR #514) already asks for parse-level validation — this ticket is that work.Suggested approach
type/ rarity, and any other number fields used in comparisons).type, string"1"(invalid or coerced per chosen policy), missingtype, and non-numeric garbage./drop,/inventory, and/statsagainst the real card folder after the change.Acceptance criteria
type(string/null/missing) cannot silently pass into drop/inventory/stats comparison paths./drop,/inventory,/statsagainst real cards still looks right.Related
docs/cards.mdeqeqeqsweep (prefer doing this validation first)QA results (step/testing → step/uat)
Tested against merged PR #518 on
release/0.12.0(bd1cd3d).Pipeline (
yarn build/yarn test/yarn lint)tsc): passjest): 17/17 suites, 118/118 tests, 8 snapshots — passeslint .): passFeature suite (
tests/Functions/CardMetadataValidator.test.ts)28/28 cases pass, covering the acceptance criteria:
typeaccepted"1", missing, null, non-numeric garbage, and out-of-rangetyperejectedidnumeric-string coercion still worksAcceptance criteria check
typecannot silently reach drop/inventory/stats comparison paths (reject-not-coerce; load aborts → safe mode via existingCardMetadataFunctioncatch)LogErrorwithjsonPath+ validation message)/drop,/inventory,/statsagainst the real card folder — not run here (noDATA_DIRcard pack in the repo / no live bot in this environment). Worth a quick human check in UAT.Moving to
step/uat.