{"record":{"id":"4f972d339ee29a25","repo":"jlcodes99/cockpit-tools","slug":"unsupported-legacy-account-json","errorCode":"unsupported_legacy_account_json","errorMessage":"unsupported_legacy_account_json","messagePattern":"unsupported_legacy_account_json","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/services/dataTransferService.ts","lineNumber":1284,"sourceCode":"    return 'zed';\n  }\n  if ('github_login' in sample || 'github_id' in sample) {\n    return 'github-copilot';\n  }\n  if ('token' in sample || ('refresh_token' in sample && 'email' in sample)) {\n    return 'antigravity';\n  }\n\n  return null;\n}\n\nasync function importLegacyAccountJson(\n  platform: PlatformId,\n  jsonContent: string,\n): Promise<AccountTransferImportResult> {\n  const importer = LEGACY_IMPORTERS[platform];\n  if (!importer) {\n    throw new Error('unsupported_legacy_account_json');\n  }\n  const imported = await importer(jsonContent);\n  const importedCount = Array.isArray(imported) ? imported.length : 0;\n  return synthesizeAccountImportResult(platform, importedCount);\n}\n\nexport function getDataTransferFileNameBase(selection: DataTransferSelection): string {\n  if (selection.includeAccounts && selection.includeConfig) {\n    return 'cockpit_data_backup';\n  }\n  if (selection.includeAccounts) {\n    return 'cockpit_accounts_backup';\n  }\n  return 'cockpit_config_backup';\n}\n\nexport async function exportDataTransferJson(selection: DataTransferSelection): Promise<string> {\n  ensureSelection(selection);","sourceCodeStart":1266,"sourceCodeEnd":1302,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/services/dataTransferService.ts#L1266-L1302","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the platform id against the keys of LEGACY_IMPORTERS (or the documented supported platforms) before importing.","Correct the casing/spelling of the PlatformId.","If the platform is genuinely unsupported, use the standard data-transfer bundle format instead of the legacy path."],"exampleFix":"// before\nawait importLegacyAccountJson(platformFromUserInput, json); // may throw\n// after\nif (!(platformFromUserInput in LEGACY_IMPORTERS)) {\n  throw new Error(`legacy import not supported for ${platformFromUserInput}`);\n}\nawait importLegacyAccountJson(platformFromUserInput, json);","handlingStrategy":"validation","validationCode":"const supportedPlatforms = ['codex']; // mirror LEGACY_IMPORTERS keys\nif (!supportedPlatforms.includes(platform)) {\n  throw new Error(`legacy account import unsupported for platform: ${platform}`);\n}","typeGuard":"function isLegacyImportSupported(platform) {\n  return typeof platform === 'string' && Object.prototype.hasOwnProperty.call(LEGACY_IMPORTERS, platform);\n}","tryCatchPattern":"try {\n  await importLegacyAccountJson(platform, json);\n} catch (e) {\n  if (e.message === 'unsupported_legacy_account_json') {\n    console.error(`Platform \"${platform}\" has no legacy importer; use the data-transfer bundle format.`);\n  } else throw e;\n}","preventionTips":["Derive the platform picker options from the importer registry keys, not a hard-coded list.","Normalize platform ids (trim/lowercase) before dispatching.","Route newly added platforms through the bundle format instead of the legacy path."],"tags":["import","legacy","unsupported-platform"],"backgroundTag":"unsupported-format","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"}