jlcodes99/cockpit-tools · error

selected_sections_missing

selected_sections_missing

Error message

selected_sections_missing

What it means

Thrown when a data-transfer bundle is structurally valid and version matches, but neither the accounts nor the config section produced an import result — i.e. the selection asked for sections the bundle does not actually contain, so nothing was imported. Warnings like account/config_section_missing are recorded first, and if both sections end up missing the import fails outright.

Source

Thrown at src/services/dataTransferService.ts:1360

      if (parsed.accounts) {
        accountResult = await importAllAccountsFromTransferJson(JSON.stringify(parsed.accounts), {
          onProgress: options.onAccountProgress,
        });
      } else {
        warnings.push('accounts_section_missing');
      }
    }

    if (options.includeConfig) {
      if (parsed.config) {
        configResult = await importConfigBundle(parsed.config);
      } else {
        warnings.push('config_section_missing');
      }
    }

    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,

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Inspect the bundle JSON and confirm which sections (accounts/config) it actually contains.
  2. Re-export with includeAccounts/includeConfig enabled for the sections you need.
  3. Align the import options with the bundle's contents (only request sections present in the file).

Example fix

// before
await importDataTransferJson(json, { includeAccounts: true, includeConfig: true });
// after
const bundle = JSON.parse(json);
const hasAccounts = Array.isArray(bundle.accounts);
const hasConfig = Boolean(bundle.config);
if (!hasAccounts && !hasConfig) throw new Error('bundle has no importable sections');
await importDataTransferJson(json, { includeAccounts: hasAccounts, includeConfig: hasConfig });
Defensive patterns

Strategy: validation

Validate before calling

const bundle = JSON.parse(json);
const hasAccounts = Array.isArray(bundle?.accounts);
const hasConfig = bundle?.config != null;
if (!hasAccounts && !hasConfig) { alert('This bundle contains neither accounts nor config.'); return; }
const options = { includeAccounts: hasAccounts, includeConfig: hasConfig };

Type guard

function hasImportableSections(b) {
  return !!b && (Array.isArray(b.accounts) || b.config != null);
}

Try / catch

try {
  await importDataTransferJson(json, options);
} catch (e) {
  if (e.message === 'selected_sections_missing') {
    console.error('Requested sections are absent from the bundle; inspect warnings and re-export with the needed sections.');
  } else throw e;
}

Prevention

When it happens

Trigger: Importing a bundle that contains only config while includeAccounts was requested (or vice versa), with the requested section absent from the file; importing a bundle where both sections are null/empty; calling the bundle path with a file that lost its sections during hand-editing.

Common situations: Export was made with a narrower selection than the import expects; file was partially edited/truncated; mismatch between what the user believes the export contains and its actual content.

Related errors


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/c4819d7b89c29e5b. Report an issue: GitHub.