A corrupt settings.json is silently reset to defaults; a null settings file crashes startup
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- electron, typescript
Research direction
Start with src/main/storage/json_file.ts:5-11 and the SettingsStore constructor in settings.ts:64-69; trace how settings and projects JSON are read and later updated. Add tests for truncated JSON retaining a .corrupt-* copy and for a null settings file starting with defaults. Done when malformed files are preserved and logged by name, invalid shapes fall back safely, and the tests pass.
Written by the indexing model from the issue text.
Description
Found in the 2026-10-07 code review and confirmed with probes.
Problem
readJson(src/main/storage/json_file.ts:5-11) returns the fallback on any parse error. The nextupdate/setSecretoverwrites the broken file, so every API key, MCP server and permission rule is gone for good.projects.json(instructions and allow-lists) behaves the same.- A file that parses to
null,[]or a string is returned asT.stored.settingsthen throws in theSettingsStoreconstructor (settings.ts:64-69), and the app doesn't start.
Scenario
A hand edit, a sync tool or a crash leaves an invalid settings.json. The next settings change wipes everything.
Fix
- In
readJson, when an existing file fails to parse, rename it to<file>.corrupt-<timestamp>and log it withappLog(names only) before returning the fallback. - Check the shape before use:
const stored = isRecord(raw) ? raw : { settings: {}, secrets: {} }, and checkstored.settingsandstored.secretstoo. - Tests: truncated JSON keeps a
.corrupt-*copy; anullfile starts with defaults.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 2
- Avg merge
- 8h 28m
- Merged PRs (30d)
- 26
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PierrunoYT/patch
-
enhancement priority: low severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PierrunoYT/patch#305 ·
Maintainers usually reply within 1 day
-
security: isAppPageUrl checks devRendererUrl with startsWith instead of comparing parsed URL originsOpenpriority: low security severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PierrunoYT/patch#300 ·
Maintainers usually reply within 1 day
-
Claude Code chats: tool calls made inside Claude Code subagents leave cards that end as "(stopped)"Openbug priority: low severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
PierrunoYT/patch#289 ·
Maintainers usually reply within 1 day
-
bug priority: medium severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PierrunoYT/patch#285 ·
Maintainers usually reply within 1 day
-
priority: medium security severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
PierrunoYT/patch#283 ·
Maintainers usually reply within 1 day
All issues in PierrunoYT/patch
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
QuantumNous/new-api#7839 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
bug p2 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getpaseo/paseo#7071 · 1 comment ·
Maintainers usually reply within 1 day
-
test: make the #3408 Claude OAuth token fixture obviously fake so secret scanners stop flagging itOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
code-yeongyu/senpi#3436 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 78/100
lingdojo/kana-dojo#32505 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day