jlcodes99/cockpit-tools · error
accounts_section_required
accounts_section_required
Error message
accounts_section_required
What it means
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.
Source
Thrown at src/services/dataTransferService.ts:1374
}
}
if (!accountResult && !configResult) {
throw new Error('selected_sections_missing');
}
return {
detected_format: 'data_bundle',
imported_account_count: accountResult?.imported_count ?? 0,
account_result: accountResult,
config_result: configResult,
warnings,
};
}
if (isAccountTransferBundleLike(parsed)) {
if (!options.includeAccounts) {
throw new Error('accounts_section_required');
}
const accountResult = await importAllAccountsFromTransferJson(jsonContent, {
onProgress: options.onAccountProgress,
});
return {
detected_format: 'account_bundle',
imported_account_count: accountResult.imported_count,
account_result: accountResult,
config_result: null,
warnings: options.includeConfig ? ['config_section_missing'] : [],
};
}
const legacyPlatform = detectLegacyPlatform(parsed);
if (!legacyPlatform) {
throw new Error('unsupported_legacy_account_json');View on GitHub (pinned to 1ed8b77992)
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.
Example fix
// before
await importDataTransferJson(accountsJson, { includeConfig: true });
// after
await importDataTransferJson(accountsJson, { includeAccounts: true, includeConfig: true }); Defensive patterns
Strategy: validation
Validate before calling
const parsed = JSON.parse(json);
const looksLikeAccounts = Array.isArray(parsed?.accounts);
if (looksLikeAccounts && !options.includeAccounts) {
alert('This file contains an accounts section — enable includeAccounts to import it.');
return;
} Type guard
function isAccountTransferBundleLike(v) {
return typeof v === 'object' && v !== null && Array.isArray(v.accounts);
} Try / catch
try {
await importDataTransferJson(json, options);
} catch (e) {
if (e.message === 'accounts_section_required') {
await importDataTransferJson(json, { ...options, includeAccounts: true });
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalidJsonMessage
- messages.rawLineNoRefreshToken(item.lineNumber)
- messages.rawLineMultipleRefreshTokens(item.lineNumber)
- messages.invalidJson
- readBundleMessage(msg) ?? readBundleMessage(message) ?? read
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/1db586efe151db68.
Report an issue: GitHub.