jlcodes99/cockpit-tools · warning

transfer_selection_required

transfer_selection_required

Error message

transfer_selection_required

What it means

ensureSelection rejects transfer selections that include nothing: both includeAccounts and includeConfig are false. Export/import functions require at least one data section to operate on. This is a guard against meaningless no-op transfers.

Source

Thrown at src/services/dataTransferService.ts:397

    return JSON.parse(value);
  } catch {
    return value;
  }
}

function safeSetLocalStorageItem(key: string, value: unknown): void {
  if (value === null || value === undefined) {
    localStorage.removeItem(key);
  } else if (typeof value === 'string') {
    localStorage.setItem(key, value);
  } else {
    localStorage.setItem(key, JSON.stringify(value));
  }
}

function ensureSelection(selection: DataTransferSelection): void {
  if (!selection.includeAccounts && !selection.includeConfig) {
    throw new Error('transfer_selection_required');
  }
}

function firstLegacySample(value: unknown): Record<string, unknown> | null {
  if (Array.isArray(value)) {
    return value.find((item) => isRecord(item)) ?? null;
  }
  return isRecord(value) ? value : null;
}

function isDataTransferBundle(value: unknown): value is DataTransferBundle {
  return isRecord(value) && value.schema === DATA_TRANSFER_SCHEMA;
}

function isAccountTransferBundleLike(value: unknown): boolean {
  return isRecord(value) && value.schema === ACCOUNT_TRANSFER_SCHEMA;
}

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Set includeAccounts: true, includeConfig: true, or both in the options object.
  2. Check selection UI state before calling and disable the submit button when nothing is selected.
  3. Verify you are passing options as the options parameter, not in a nested/wrong field.

Example fix

// before
await exportDataTransferJson({ includeAccounts: false, includeConfig: false });
// after
await exportDataTransferJson({ includeAccounts: true, includeConfig: true });
Defensive patterns

Strategy: validation

Validate before calling

function selectionIsValid(sel) {
  return Boolean(sel && (sel.includeAccounts || sel.includeConfig));
}
if (!selectionIsValid(options)) { alert('Select at least one section (accounts or config).'); return; }

Try / catch

try {
  await exportDataTransferJson(options);
} catch (e) {
  if (e.message === 'transfer_selection_required') {
    console.error('Nothing selected: enable includeAccounts and/or includeConfig.');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling exportDataTransferJson or importDataTransferJson with { includeAccounts: false, includeConfig: false } (or omitting both flags so they default to false); constructing options programmatically and forgetting to set either flag.

Common situations: UI form where the user unchecked every checkbox; defaults object built without the flags; conditional logic that disabled both sections after validation.

Related errors


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