{"record":{"id":"0f404297455cf2c0","repo":"actualbudget/actual","slug":"error-exporting-budget-result-error","errorCode":null,"errorMessage":"Error exporting budget: ${result.error}","messagePattern":"Error exporting budget: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/api/methods.ts","lineNumber":91,"sourceCode":"          filename,\n          type,\n        });\n\n  if (result.error) {\n    throw new Error(`Error importing budget: ${result.error}`);\n  }\n  if (!result.id) {\n    throw new Error('Error importing budget: no budget was loaded');\n  }\n  return { id: result.id };\n}\n\n/** Export the currently-loaded budget as a zip buffer. */\nexport async function exportBudget(): Promise<Uint8Array> {\n  const result = await send('export-budget');\n\n  if ('error' in result) {\n    throw new Error(`Error exporting budget: ${result.error}`);\n  }\n  if (!result.data) {\n    throw new Error('Error exporting budget: no data was returned');\n  }\n  return new Uint8Array(result.data);\n}\n\nfunction toArrayBuffer(data: ArrayBuffer | Uint8Array): ArrayBuffer {\n  if (data instanceof Uint8Array) {\n    // Copy into a fresh ArrayBuffer so that views into a larger (possibly\n    // shared) buffer are not sent across the worker boundary as-is.\n    const copy = new Uint8Array(data.byteLength);\n    copy.set(data);\n    return copy.buffer;\n  }\n  return data;\n}\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/api/methods.ts#L73-L109","documentation":"exportBudget sends 'export-budget' to serialize the currently loaded budget into a zip buffer. If the core returns an error field, this is thrown with the detail. It means the export of the active budget failed server-side (disk/serialization problem or no usable budget).","triggerScenarios":"Calling api.exportBudget() when the underlying core export fails: active budget in a broken state, low disk/memory during zipping, or internal error while building the export archive.","commonSituations":"Scheduled backup jobs exporting budgets from a long-running API process; exporting right after a failed migration; server under memory pressure with very large budgets.","solutions":["Read the detail in the thrown message to identify the core-side cause.","Ensure a valid budget is loaded before exporting (loadBudget / successful open).","Retry the export after restarting the API/server process to clear a bad in-memory state.","Check available disk space and memory on the machine running the export."],"exampleFix":"// before\nconst data = await api.exportBudget();\n// after\nlet data;\ntry {\n  data = await api.exportBudget();\n} catch (e) {\n  console.error('Budget export failed:', e.message);\n  await api.loadBudget(budgetId); // re-load a known-good budget\n  data = await api.exportBudget();\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const zip = await api.exportBudget();\n} catch (e) {\n  if (String(e.message).startsWith('Error exporting budget:')) {\n    console.error('Export failed:', e.message);\n    // re-load budget and retry once, else alert backup pipeline\n  } else throw e;\n}","preventionTips":["Ensure a budget is loaded before exporting.","Monitor disk space and memory on the exporting host.","Run exports in a retry wrapper with backoff in backup jobs.","Keep core/server versions aligned."],"tags":["export","budget","api","backup"],"backgroundTag":"budget-export-failed","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}