JSON formatter: a duplicate key crashes the whole tool
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- next.js, typescript
- Lĩnh vực
- developer-experience, frontend
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 1
- Fork
- 9
- Merge trung bình
- 7 giờ 30 phút
- Pull request đã merge (30 ngày)
- 151
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codercops/toolbelt
-
fix(UI): shortcut popover overflowsCó thể đã có người làm @DeepakNegi13 đã nhận 1 ngày trước. Đang mởbug good first issue hacktoberfest
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
codercops/toolbelt#333 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Timestamp converter turns "February 30, 2024" into March 1 instead of rejecting itCó thể đã có người làm @bhushan4work đã nhận 1 ngày trước. Đang mởbug hacktoberfest help wanted
codercops/toolbelt#337 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Copy buttons in the URL encoder and JWT decoder are all named just "Copy"Có thể đã có người làm @bhushan4work đã nhận 1 ngày trước. Đang mởaccessibility bug good first issue hacktoberfest
codercops/toolbelt#335 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Cron explainer says "on weekdays" for `0 0 1-31 * 1-5`, but the next runs include weekendsCó thể đã có người làm @Saifjafri212213 đã nhận 2 ngày trước. Đang mởbug hacktoberfest help wanted
codercops/toolbelt#329 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
UUID generator's v7 batch comes out in random order instead of time orderCó thể đã có người làm @omisha123 đã nhận 2 ngày trước. Đang mởbug good first issue hacktoberfest
codercops/toolbelt#316 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của codercops/toolbelt
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
pingdotgg/t3code#24900 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
inu-appcenter/UNIDorm-web#411 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ranxianglei/billion-context#4720 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:arcade game p3-medium ready-for-agent type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
fderuiter/deruiter.dev#2840 ·
Maintainer thường phản hồi trong vòng 1 ngày