Problem
readConfig wraps the whole read/parse/decrypt pipeline in a bare catch {} that returns null on any error. If the config file is corrupted (partial write, disk error, bad manual edit), the user sees a completely empty app — all gateway configurations, language settings, and preferences silently disappear. No error is logged and no backup is kept, so recovery is impossible.
Location
File: packages/desktop/src/main/workspace/config.ts:155-166
export function readConfig(): AppConfig | null {
const cfgPath = configFilePath();
if (!existsSync(cfgPath)) return null;
try {
const raw = readFileSync(cfgPath, 'utf-8');
const config = JSON.parse(raw) as AppConfig;
const migrated = migrateConfigIfNeeded(config);
return decryptGatewayCredentials(migrated);
} catch {
return null;
}
}
Fix Approach
- In the catch block, log the error via
console.error('[config] failed to read:', err).
- Rename the corrupted file to
config.json.corrupted-<ISO timestamp> so the user has a recovery artifact on disk.
- Return
null as before, so the first-run flow still kicks in.
Verification
- Run
pnpm check — must pass.
- Manual: write garbage into the config file, launch the app, check that:
- The corrupted file is renamed with a
.corrupted-* suffix.
- The main process log contains the error.
- The app still launches into the first-run flow.
Context
- WG: Artifact & File System
- Priority: Low (good first issue)
- Estimated effort: 20-30 minutes
Problem
readConfigwraps the whole read/parse/decrypt pipeline in a barecatch {}that returnsnullon any error. If the config file is corrupted (partial write, disk error, bad manual edit), the user sees a completely empty app — all gateway configurations, language settings, and preferences silently disappear. No error is logged and no backup is kept, so recovery is impossible.Location
File:
packages/desktop/src/main/workspace/config.ts:155-166Fix Approach
console.error('[config] failed to read:', err).config.json.corrupted-<ISO timestamp>so the user has a recovery artifact on disk.nullas before, so the first-run flow still kicks in.Verification
pnpm check— must pass..corrupted-*suffix.Context