{"record":{"id":"7cec6c24fd25a2cd","repo":"actualbudget/actual","slug":"json-parse-error","errorCode":"json-parse-error","errorMessage":"Invalid JSON file.","messagePattern":"Invalid JSON file\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/loot-core/src/server/dashboard/app.ts","lineNumber":344,"sourceCode":"                Object.entries(reportModel.fromJS(meta)).map(([key, value]) => [\n                  key,\n                  value ?? null,\n                ]),\n              ),\n              tombstone: false,\n            }),\n          ),\n      ]);\n    });\n\n    return { status: 'ok' as const };\n  } catch (err: unknown) {\n    if (err instanceof Error) {\n      err.message = 'Error importing file: ' + err.message;\n      captureException(err);\n    }\n    if (err instanceof SyntaxError) {\n      throw new Error('Invalid JSON file.', { cause: 'json-parse-error' });\n    }\n    if (err instanceof ValidationError) {\n      throw new Error(err.message, { cause: 'validation-error' });\n    }\n    throw new Error('Internal error occurred during import.', {\n      cause: 'internal-error',\n    });\n  }\n}\n\nexport type DashboardHandlers = {\n  'dashboard-create': typeof createDashboardPage;\n  'dashboard-delete': typeof deleteDashboardPage;\n  'dashboard-rename': typeof renameDashboardPage;\n  'dashboard-update': typeof updateDashboard;\n  'dashboard-update-widget': typeof updateDashboardWidget;\n  'dashboard-reset': typeof resetDashboard;\n  'dashboard-add-widget': typeof addDashboardWidget;","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/loot-core/src/server/dashboard/app.ts#L326-L362","documentation":"When JSON.parse of the imported file throws a SyntaxError, importDashboard converts it into `Error('Invalid JSON file.', { cause: 'json-parse-error' })`. The cause code lets the client distinguish malformed JSON from validation or internal failures.","triggerScenarios":"Importing a dashboard file that is empty, truncated, contains trailing commas/comments, is not JSON at all (e.g. an HTML error page), or has a BOM/encoding issue.","commonSituations":"Downloading the export link and saving an error page; manually editing the file and breaking JSON; partial file transfer.","solutions":["Validate the file locally with `JSON.parse(fs.readFileSync(p,'utf8'))` or `jq . file.json` to find the syntax error.","Re-export the dashboard from Actual and use the fresh file unmodified.","Ensure the file is saved as UTF-8 without BOM and ends cleanly."],"exampleFix":"// before (broken JSON)\n{ \"version\": 1, \"widgets\": [ {...}, ] }\n// after\n{ \"version\": 1, \"widgets\": [ {...} ] }","handlingStrategy":"validation","validationCode":"try {\n  JSON.parse(fs.readFileSync(filePath, 'utf8').replace(/^\\uFEFF/, ''));\n} catch (e) {\n  throw new Error(`Import file is not valid JSON: ${(e as SyntaxError).message}`);\n}","typeGuard":"function isValidJson(text: string): boolean {\n  try { JSON.parse(text); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  await send('dashboard-import', { filePath, dashboardPageId });\n} catch (e) {\n  if (e.cause === 'json-parse-error') {\n    console.error('The dashboard file is not valid JSON; re-export it.');\n  }\n}","preventionTips":["Run `jq . file.json` (or JSON.parse) on the export before importing.","Don't edit exported JSON with tools that emit comments or trailing commas.","Ensure the download completed fully and was saved as UTF-8 without BOM."],"tags":["json","import","parse-error"],"backgroundTag":"invalid-json","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}