Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

A corrupt settings.json is silently reset to defaults; a null settings file crashes startup

Closed
#168 0 comments 0 reactions 0 assignees View on GitHub

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
Domain
backend, desktop

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

bug priority: high severity: medium

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 next update/setSecret overwrites 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 as T. stored.settings then throws in the SettingsStore constructor (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 with appLog (names only) before returning the fallback.
  • Check the shape before use: const stored = isRecord(raw) ? raw : { settings: {}, secrets: {} }, and check stored.settings and stored.secrets too.
  • Tests: truncated JSON keeps a .corrupt-* copy; a null file starts with defaults.
Dominant language
TypeScript
Stars
2
Forks
2
Avg merge
8h 28m
Merged PRs (30d)
26

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PierrunoYT/patch

All issues in PierrunoYT/patch

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.