jlcodes99/cockpit-tools · error

invalid_bundle_version

invalid_bundle_version

Error message

invalid_bundle_version

What it means

The transfer bundle's 'version' field does not equal ACCOUNT_TRANSFER_VERSION, so the importer refuses bundles from incompatible versions. This prevents silently misreading fields whose meaning changed between versions.

Source

Thrown at src/services/accountTransferService.ts:339

}

export async function exportAllAccountsTransferJson(): Promise<string> {
  const bundle = await buildAccountTransferBundle();
  return JSON.stringify(bundle, null, 2);
}

function parseAccountTransferBundle(jsonContent: string): Record<PlatformId, AccountTransferPlatformPayload> {
  const parsed = parseJsonOrThrow(jsonContent, 'invalid_json');
  if (!isRecord(parsed)) {
    throw new Error('invalid_bundle_root');
  }

  if (parsed.schema !== ACCOUNT_TRANSFER_SCHEMA) {
    throw new Error('invalid_bundle_schema');
  }

  if (parsed.version !== ACCOUNT_TRANSFER_VERSION) {
    throw new Error('invalid_bundle_version');
  }

  const rawPlatforms = parsed.platforms;
  if (!isRecord(rawPlatforms)) {
    throw new Error('invalid_bundle_platforms');
  }

  const platforms: Record<PlatformId, AccountTransferPlatformPayload> = {} as Record<
    PlatformId,
    AccountTransferPlatformPayload
  >;

  for (const platform of ALL_PLATFORM_IDS) {
    const resolved = resolvePlatformPayload(rawPlatforms[platform]);
    platforms[platform] =
      resolved ??
      ({
        account_count: 0,

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Re-export the bundle with the current application version so version matches ACCOUNT_TRANSFER_VERSION
  2. Upgrade the importing application to a version that accepts the bundle's version
  3. Bump the bundle's version field manually only if the payload format is genuinely unchanged
  4. Add a migration path in code for older versions instead of editing files by hand

Example fix

// before
{ "schema": "...", "version": "1", ... }
// after
{ "schema": "...", "version": 1, ... }  // matches ACCOUNT_TRANSFER_VERSION
Defensive patterns

Strategy: validation

Validate before calling

const obj = JSON.parse(text);
if (obj.version !== ACCOUNT_TRANSFER_VERSION) throw new Error('invalid_bundle_version');

Type guard

function hasValidVersion(v: Record<string, unknown>, expected: number): boolean {
  return typeof v.version === 'number' && v.version === expected;
}

Try / catch

try {
  await importBundle(text);
} catch (e) {
  if (e instanceof Error && e.message === 'invalid_bundle_version') {
    alert('Bundle version not supported — update the app or re-export the bundle.');
  } else throw e;
}

Prevention

When it happens

Trigger: parsed.schema matches but parsed.version !== ACCOUNT_TRANSFER_VERSION — older or newer export, missing version key (undefined), or version as a string instead of number.

Common situations: Importing a bundle exported by an older app release after a breaking change, hand-written bundles omitting version, JSON produced with "version": "1" instead of 1.

Related errors


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