Unexpected saved data can stop the hub from rendering

Aperta
#16 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript, vite
Ambito
frontend

Direzione di ricerca

Start with shared/storage.ts and trace how settings and achievements are loaded in shared/settings.ts and shared/achievements.ts; then inspect panel setup in src/hub/main.ts and src/hub/settings-panel.ts. Reproduce the issue with the provided localStorage value, then run npm run typecheck and npm run build. Done when malformed or partial saved values use defaults without throwing and the game grid renders despite a panel initialization failure.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug severity: low

Summary

Saved data is cast to its expected type without any shape check or version field. A value from an older or newer schema, or one edited by hand, can throw during hub start-up and leave an empty game grid with no message.

Where

  • shared/storage.ts:7 (JSON.parse(raw) as T)
  • shared/settings.ts:59, shared/achievements.ts:91 (spread over defaults)
  • src/hub/settings-panel.ts:54 (PALETTES[s.palette] with no fallback; shared/ui.ts:9 does guard this)
  • src/hub/main.ts:110-111 (panels are wired before the grid renders)

Steps to reproduce

  1. In devtools: localStorage.setItem('gh-arcade:settings', '{"palette":"x"}').
  2. Reload the hub: no game cards appear.

Suggested fix

Add per-key sanitisers that coerce and default each field (numbers via Number.isFinite, known palette names, object-typed sections), add a version field, and render the game grid before wiring the panels so one bad panel cannot hide the games.

Acceptance criteria

  • Malformed or partial saved values fall back to defaults without throwing
  • The game grid renders even if a panel fails to initialise

Getting started

  • Relevant files: shared/storage.ts, shared/settings.ts, shared/achievements.ts, src/hub/main.ts, src/hub/settings-panel.ts
  • Run locally: npm install, then npm run dev
  • Checks: npm run typecheck and npm run build (there is no test suite yet)
  • Related docs: README.md

Related: #1


Filed by repo-audit/full-audit at b001f5d. Severity: low. Effort: S. audit-key: quality|shared/storage.ts|loadJSON

Lingua principale
TypeScript
Stelle
3
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TMHSDigital/GH-Arcade

Tutte le issue di TMHSDigital/GH-Arcade

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.