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
- Re-export the bundle with the current application version so version matches ACCOUNT_TRANSFER_VERSION
- Upgrade the importing application to a version that accepts the bundle's version
- Bump the bundle's version field manually only if the payload format is genuinely unchanged
- 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
- Re-export bundles after any application upgrade
- Serialize version as a number, never a string
- Document breaking version changes and provide migration on import
- Check the bundle's version field before importing older archives
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
- invalid_bundle_schema
- invalid_bundle_root
- invalid_bundle_platforms
- backup_accounts_missing
- [ExternalImport][App] payload 归一化失败,已忽略
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/56f4a6895fcc8e78.
Report an issue: GitHub.