{"record":{"id":"c4588df52bcb4528","repo":"Foundry376/Mailspring","slug":"config-json-appears-empty","errorCode":null,"errorMessage":"config json appears empty","messagePattern":"config json appears empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/browser/config-persistence-manager.ts","lineNumber":90,"sourceCode":"      detail,\n      buttons: [localized('Quit'), localized('Try Again'), localized('Reset Configuration')],\n    });\n\n    // On Windows, `cancelId` is ignored by Electron, so dismissing the dialog without\n    // clicking a button (eg: via the window's close button, Alt+F4, or Esc) can return\n    // an index outside 0-2. Treat that the same as \"Quit\" rather than throwing, since\n    // this runs synchronously during app startup and an uncaught error here prevents\n    // the app from launching at all.\n    return ['quit', 'tryagain', 'reset'][clickedIndex] || 'quit';\n  }\n\n  load() {\n    this.userWantsToPreserveErrors = false;\n\n    try {\n      const json = JSON.parse(fs.readFileSync(this.configFilePath).toString());\n      if (!json || !json['*']) {\n        throw new Error('config json appears empty');\n      }\n      this.settings = json['*'];\n      this.emitChangeEvent();\n    } catch (error) {\n      error.message = localized(`Failed to load config.json: %@`, error.message);\n\n      const action = this._showLoadErrorDialog(error);\n      if (action === 'quit') {\n        this.userWantsToPreserveErrors = true;\n        app.quit();\n        return;\n      }\n\n      if (action === 'tryagain') {\n        this.load();\n        return;\n      }\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/src/browser/config-persistence-manager.ts#L72-L108","documentation":"Startup validation in ConfigPersistenceManager.load: the user's config.json parsed to an empty/whitespace payload (e.g. truncated by a crash or power loss mid-write), so the config cannot be loaded. It drives the dialog offering Quit, Try Again, or Reset Configuration.","triggerScenarios":"Thrown at app/src/browser/config-persistence-manager.ts:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose 'Try Again' if the file may have been momentarily locked (antivirus, sync agent)","Choose 'Reset Configuration' to regenerate a fresh config and re-onboard accounts","Write config atomically (temp file + rename) to prevent truncation in the first place"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"648c685d602ece6bb00c22534b8734de6ac644b3","analyzedAt":"2026-09-03T02:00:24.311Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}