clawwork-ai/ClawWork
View on GitHub[Bug] readConfig silently returns null on parse errors, losing user config
Open
#384 opened on Apr 15, 2026
area/artifactgood first issuekind/bug
Repository metrics
- Stars
- (519 stars)
- PR merge metrics
- (PR metrics pending)
Description
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
nullas 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.
- The corrupted file is renamed with a
Context
- WG: Artifact & File System
- Priority: Low (good first issue)
- Estimated effort: 20-30 minutes