jlcodes99/cockpit-tools · error

unsupported_legacy_account_json

unsupported_legacy_account_json

Error message

unsupported_legacy_account_json

What it means

importLegacyAccountJson looks up an importer in LEGACY_IMPORTERS by platform id; if none is registered for that platform the import cannot proceed and this error is thrown. Only platforms with a defined legacy importer are supported for account JSON import.

Source

Thrown at src/services/dataTransferService.ts:1284

    return 'zed';
  }
  if ('github_login' in sample || 'github_id' in sample) {
    return 'github-copilot';
  }
  if ('token' in sample || ('refresh_token' in sample && 'email' in sample)) {
    return 'antigravity';
  }

  return null;
}

async function importLegacyAccountJson(
  platform: PlatformId,
  jsonContent: string,
): Promise<AccountTransferImportResult> {
  const importer = LEGACY_IMPORTERS[platform];
  if (!importer) {
    throw new Error('unsupported_legacy_account_json');
  }
  const imported = await importer(jsonContent);
  const importedCount = Array.isArray(imported) ? imported.length : 0;
  return synthesizeAccountImportResult(platform, importedCount);
}

export function getDataTransferFileNameBase(selection: DataTransferSelection): string {
  if (selection.includeAccounts && selection.includeConfig) {
    return 'cockpit_data_backup';
  }
  if (selection.includeAccounts) {
    return 'cockpit_accounts_backup';
  }
  return 'cockpit_config_backup';
}

export async function exportDataTransferJson(selection: DataTransferSelection): Promise<string> {
  ensureSelection(selection);

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Check the platform id against the keys of LEGACY_IMPORTERS (or the documented supported platforms) before importing.
  2. Correct the casing/spelling of the PlatformId.
  3. If the platform is genuinely unsupported, use the standard data-transfer bundle format instead of the legacy path.

Example fix

// before
await importLegacyAccountJson(platformFromUserInput, json); // may throw
// after
if (!(platformFromUserInput in LEGACY_IMPORTERS)) {
  throw new Error(`legacy import not supported for ${platformFromUserInput}`);
}
await importLegacyAccountJson(platformFromUserInput, json);
Defensive patterns

Strategy: validation

Validate before calling

const supportedPlatforms = ['codex']; // mirror LEGACY_IMPORTERS keys
if (!supportedPlatforms.includes(platform)) {
  throw new Error(`legacy account import unsupported for platform: ${platform}`);
}

Type guard

function isLegacyImportSupported(platform) {
  return typeof platform === 'string' && Object.prototype.hasOwnProperty.call(LEGACY_IMPORTERS, platform);
}

Try / catch

try {
  await importLegacyAccountJson(platform, json);
} catch (e) {
  if (e.message === 'unsupported_legacy_account_json') {
    console.error(`Platform "${platform}" has no legacy importer; use the data-transfer bundle format.`);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the legacy account import with a platformId not present in LEGACY_IMPORTERS (e.g. a new/renamed platform, or an id with wrong casing); dispatching a user-selected platform string straight into the importer without checking support.

Common situations: Platform list in UI out of sync with supported legacy importers; typos like 'codex_cli' vs 'codex'; platform introduced after the legacy import table was written.

Related errors


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