JSON formatter: a duplicate key crashes the whole tool
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- next.js, typescript
- Ambito
- developer-experience, frontend
Direzione di ricerca
Start with lib/json-utils.ts, comparing the six llParse(raw) call sites with the existing error handling in format() and minify(). Add focused tests for toCSV, toTypeScript, toYAML, toXML, toQueryString, and sortKeys, then verify that the conversion panel remains on the page. Run npm run lint, npm run test, and npm run build; an open linked PR already exists for issue #222.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Paste this into the JSON formatter:
{"a": 1, "a": 2}
The whole tool is replaced by "This tool hit an unexpected error" (app/error.tsx).
validate() (lib/json-utils.ts, line 71) checks the input with JSON.parse, which accepts a duplicate key and keeps the last value. The conversions then parse the input again with lossless-json, which throws Duplicate key 'a' encountered at position 10. format() and minify() catch that and return it as an error (lines 91 to 95), but these six don't:
toCSV(line 137),toTypeScript(line 315),toYAML(line 422),toXML(line 580) andtoQueryString(line 623)sortKeys(line 503)
The conversion panel runs one of them while it renders (ConversionPanel.tsx, line 49, and TypeScript is the default mode), so the error reaches the error page. Sort keys throws from its click handler (JsonFormatterClient.tsx, line 109) instead of showing a message.
What to do
- Catch the parse error in those six functions and return
{ ok: false, error: parseSyntaxError(raw, e) }, the wayformat()does. One small helper that all six call is fine. - The panel and Sort keys then show "Duplicate key 'a' encountered at position 10", like Format does, and the page stays up.
Where to look
lib/json-utils.ts:validate(line 71),format(line 86) and the sixllParse(raw)calls aboveapp/(tools)/json-formatter/components/ConversionPanel.tsx: theuseMemoat line 49lib/__tests__/json-tree.test.tsrenders a component withrenderToStaticMarkup, if you also want a test for the panel
Acceptance criteria
- With
{"a": 1, "a": 2}in the editor, the page stays up, and the TypeScript, CSV, YAML, XML and Query string modes show the duplicate key error - Sort keys shows the same error
- Tests: each of the six functions returns
ok: falsefor a duplicate key (they throw on the current code) -
npm run lint,npm run testandnpm run buildpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #218 in the description.
- Lingua principale
- TypeScript
- Stelle
- 1
- Fork
- 9
- Merge medio
- 10h 24m
- PR unite (30g)
- 93
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di codercops/toolbelt
-
bug good first issue hacktoberfest
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue hacktoberfest
Difficoltà 2/5 1-3 ore Idoneità per principianti 94/100
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue hacktoberfest
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
Stop the JSON formatter's Find bar from typing into the JSONForse già presa @kudala-bharani l’ha presa 2 giorni fa. Apertabug hacktoberfest help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
codercops/toolbelt#121 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
JSON to XML: keys like `@type`, `$ref` or `bad key` turn into `<item>`Forse già presa @AyanZahid-Code l’ha presa 1 giorno fa. Apertabug good first issue hacktoberfest
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
codercops/toolbelt#214 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di codercops/toolbelt
Issue simili
-
ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
xavxyz/bei-shan-lin-shui#57 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] rag: sentence content can cross the reported sentence boundariesForse già presa @LJK-ikun l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URIAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
platformatic/mcp#361 ·
I maintainer di solito rispondono entro 1 giorno
-
最近文档这个弹窗,左右宽度没有最小宽度限制Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
siyuan-note/siyuan#20799 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno