{"record":{"id":"1db586efe151db68","repo":"jlcodes99/cockpit-tools","slug":"accounts-section-required","errorCode":"accounts_section_required","errorMessage":"accounts_section_required","messagePattern":"accounts_section_required","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/services/dataTransferService.ts","lineNumber":1374,"sourceCode":"      }\n    }\n\n    if (!accountResult && !configResult) {\n      throw new Error('selected_sections_missing');\n    }\n\n    return {\n      detected_format: 'data_bundle',\n      imported_account_count: accountResult?.imported_count ?? 0,\n      account_result: accountResult,\n      config_result: configResult,\n      warnings,\n    };\n  }\n\n  if (isAccountTransferBundleLike(parsed)) {\n    if (!options.includeAccounts) {\n      throw new Error('accounts_section_required');\n    }\n\n    const accountResult = await importAllAccountsFromTransferJson(jsonContent, {\n      onProgress: options.onAccountProgress,\n    });\n\n    return {\n      detected_format: 'account_bundle',\n      imported_account_count: accountResult.imported_count,\n      account_result: accountResult,\n      config_result: null,\n      warnings: options.includeConfig ? ['config_section_missing'] : [],\n    };\n  }\n\n  const legacyPlatform = detectLegacyPlatform(parsed);\n  if (!legacyPlatform) {\n    throw new Error('unsupported_legacy_account_json');","sourceCodeStart":1356,"sourceCodeEnd":1392,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/services/dataTransferService.ts#L1356-L1392","documentation":"Thrown when the parsed content matches an account-transfer bundle shape but the import options did not set includeAccounts. Account-style bundles can only be imported through the accounts path, so requiring that flag is mandatory; without it the importer refuses rather than silently ignore the section.","triggerScenarios":"Calling importDataTransferJson with an accounts-only transfer JSON while options.includeAccounts is false/omitted; reusing a shared options object where includeAccounts defaults to false for account-like files.","commonSituations":"Importing an accounts export saved earlier without realizing it is not a full bundle; copying import options from a config-only import snippet; UI forgetting to tick 'accounts' when the file contains accounts.","solutions":["Set includeAccounts: true in the import options.","Detect the bundle shape first (isAccountTransferBundleLike on parsed JSON) and set flags accordingly before calling.","If a full bundle was intended, re-export with both sections enabled."],"exampleFix":"// before\nawait importDataTransferJson(accountsJson, { includeConfig: true });\n// after\nawait importDataTransferJson(accountsJson, { includeAccounts: true, includeConfig: true });","handlingStrategy":"validation","validationCode":"const parsed = JSON.parse(json);\nconst looksLikeAccounts = Array.isArray(parsed?.accounts);\nif (looksLikeAccounts && !options.includeAccounts) {\n  alert('This file contains an accounts section — enable includeAccounts to import it.');\n  return;\n}","typeGuard":"function isAccountTransferBundleLike(v) {\n  return typeof v === 'object' && v !== null && Array.isArray(v.accounts);\n}","tryCatchPattern":"try {\n  await importDataTransferJson(json, options);\n} catch (e) {\n  if (e.message === 'accounts_section_required') {\n    await importDataTransferJson(json, { ...options, includeAccounts: true });\n  } else throw e;\n}","preventionTips":["Pre-parse the file and enable includeAccounts automatically when an accounts section is detected.","Don't share one default options object across account-only and bundle imports.","In UI, auto-check the 'accounts' flag when the selected file contains accounts."],"tags":["import","options","accounts"],"backgroundTag":"missing-section","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}