Unexpected saved data can stop the hub from rendering

Aberta
#16 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
typescript, vite
Domínio
frontend

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
TypeScript
Estrelas
3
Forks
3
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de TMHSDigital/GH-Arcade

Todas as issues de TMHSDigital/GH-Arcade

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.