{"record":{"id":"2f648ebe2bda51d9","repo":"jlcodes99/cockpit-tools","slug":"invalid-bundle-version-2f648e","errorCode":"invalid_bundle_version","errorMessage":"invalid_bundle_version","messagePattern":"invalid_bundle_version","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/services/dataTransferService.ts","lineNumber":1334,"sourceCode":"\n  if (selection.includeConfig) {\n    const registry = await loadAccountRegistry();\n    bundle.config = await exportConfigBundle(registry);\n  }\n\n  return JSON.stringify(bundle, null, 2);\n}\n\nexport async function importDataTransferJson(\n  jsonContent: string,\n  options: DataTransferImportOptions,\n): Promise<DataTransferImportResult> {\n  ensureSelection(options);\n  const parsed = parseJsonOrThrow(jsonContent, 'invalid_json');\n\n  if (isDataTransferBundle(parsed)) {\n    if (parsed.version !== DATA_TRANSFER_VERSION) {\n      throw new Error('invalid_bundle_version');\n    }\n\n    const warnings: DataTransferWarningCode[] = [];\n    let accountResult: AccountTransferImportResult | null = null;\n    let configResult: DataTransferConfigImportResult | null = null;\n\n    if (options.includeAccounts) {\n      if (parsed.accounts) {\n        accountResult = await importAllAccountsFromTransferJson(JSON.stringify(parsed.accounts), {\n          onProgress: options.onAccountProgress,\n        });\n      } else {\n        warnings.push('accounts_section_missing');\n      }\n    }\n\n    if (options.includeConfig) {\n      if (parsed.config) {","sourceCodeStart":1316,"sourceCodeEnd":1352,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/services/dataTransferService.ts#L1316-L1352","documentation":"Thrown during data-transfer import when the parsed JSON looks like a data-transfer bundle but its version field does not equal DATA_TRANSFER_VERSION. The importer only accepts bundles produced by the exact same schema version; forward/backward versions are rejected explicitly.","triggerScenarios":"Importing a bundle exported by an older or newer app version whose DATA_TRANSFER_VERSION differs; hand-editing the version field; passing a similar-looking object (e.g. from another tool) that passes isDataTransferBundle but has a foreign version.","commonSituations":"Upgrading or downgrading the app between export and import; sharing export files between machines with different app versions; testing with fixtures copied from an old release.","solutions":["Re-export the data with the current app version so the bundle carries DATA_TRANSFER_VERSION.","Open the JSON and check the version field against the version the running app expects.","If the old bundle must be kept, migrate it (or use the old app version) to import it."],"exampleFix":"// before\nawait importDataTransferJson(oldExportJson, options); // version: 1\n// after\nconst parsed = JSON.parse(oldExportJson);\nif (parsed.version !== 2) {\n  parsed.version = 2; // or re-export from the upgraded app\n}\nawait importDataTransferJson(JSON.stringify(parsed), options);","handlingStrategy":"type-guard","validationCode":"function bundleVersionMatches(parsed, expectedVersion) {\n  return typeof parsed === 'object' && parsed !== null\n    && 'version' in parsed && parsed.version === expectedVersion;\n}\nconst parsed = JSON.parse(json);\nif (!bundleVersionMatches(parsed, 2)) { alert('Bundle version mismatch — re-export from the current app version.'); return; }","typeGuard":"function isCurrentBundle(v) {\n  return typeof v === 'object' && v !== null && 'version' in v && typeof v.version === 'number' && v.version === DATA_TRANSFER_VERSION;\n}","tryCatchPattern":"try {\n  await importDataTransferJson(json, options);\n} catch (e) {\n  if (e.message === 'invalid_bundle_version') {\n    const v = JSON.parse(json)?.version;\n    console.error(`Bundle version ${v} != expected ${DATA_TRANSFER_VERSION}; re-export the data.`);\n  } else throw e;\n}","preventionTips":["Check the version field right after parsing, before importing.","Re-export data after upgrading the app rather than reusing old bundles.","Show the expected version in the import dialog so users can compare."],"tags":["versioning","import","bundle"],"backgroundTag":"version-mismatch","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"}