{"record":{"id":"d430c6ba18e4bb86","repo":"actualbudget/actual","slug":"error-importing-budget-no-budget-was-loaded","errorCode":null,"errorMessage":"Error importing budget: no budget was loaded","messagePattern":"Error importing budget: no budget was loaded","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/api/methods.ts","lineNumber":81,"sourceCode":"  {\n    type = 'actual',\n    filename,\n  }: { type?: ImportableBudgetType; filename?: string } = {},\n): Promise<{ id: string }> {\n  const result =\n    typeof input === 'string'\n      ? await send('import-budget', { filepath: input, type })\n      : await send('import-budget', {\n          buffer: toArrayBuffer(input),\n          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 {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/api/methods.ts#L63-L99","documentation":"After the 'import-budget' command reports success, the API checks that a budget id came back. If result.id is missing, something accepted the file but no budget was actually loaded, so the API throws rather than returning an unusable id. This is a defensive consistency check in packages/api/methods.ts.","triggerScenarios":"The core import handler resolves without an explicit error but fails to set the returned budget id — typically a silent success path in the import handler or an unexpected response shape from send('import-budget').","commonSituations":"Version mismatch between @actual-app/api and the core/server where the response contract changed; importing into a server session that did not fully initialize.","solutions":["Align @actual-app/api and the sync-server/core to the same version (yarn install / rebuild).","Log the raw response of the import by calling send('import-budget') directly (loot-core) to see what id was returned.","Retry the import; verify the file opens correctly in the Actual UI.","Report upstream with the file and versions if it reproduces."],"exampleFix":"// before\nconst { id } = await api.importBudget(buf, 'budget.zip', 'application/zip');\n// after\nlet result;\ntry {\n  result = await api.importBudget(buf, 'budget.zip', 'application/zip');\n} catch (e) {\n  if (String(e.message).includes('no budget was loaded')) {\n    // check api/core version parity before retrying\n    throw new Error('Import returned no budget id — check @actual-app/api and server versions');\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"function hasBudgetId(r: unknown): r is { id: string } {\n  return typeof r === 'object' && r !== null && typeof (r as { id?: unknown }).id === 'string' && (r as { id: string }).id.length > 0;\n}","tryCatchPattern":"try {\n  const { id } = await api.importBudget(buf, 'budget.zip', 'application/zip');\n} catch (e) {\n  if (String(e.message).includes('no budget was loaded')) {\n    // version/contract mismatch — check api vs server versions and retry\n    throw new Error('Import succeeded but no budget id returned; verify package versions');\n  }\n  throw e;\n}","preventionTips":["Keep @actual-app/api, loot-core, and sync-server versions in lockstep.","After upgrades, restart the API process before importing.","Test imports against a scratch budget file after every dependency bump.","Report persistent no-id imports upstream with versions."],"tags":["import","budget","api","version-mismatch"],"backgroundTag":"budget-import-failed","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}