jlcodes99/cockpit-tools · error
invalid_bundle_version
invalid_bundle_version
Error message
invalid_bundle_version
What it means
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.
Source
Thrown at src/services/dataTransferService.ts:1334
if (selection.includeConfig) {
const registry = await loadAccountRegistry();
bundle.config = await exportConfigBundle(registry);
}
return JSON.stringify(bundle, null, 2);
}
export async function importDataTransferJson(
jsonContent: string,
options: DataTransferImportOptions,
): Promise<DataTransferImportResult> {
ensureSelection(options);
const parsed = parseJsonOrThrow(jsonContent, 'invalid_json');
if (isDataTransferBundle(parsed)) {
if (parsed.version !== DATA_TRANSFER_VERSION) {
throw new Error('invalid_bundle_version');
}
const warnings: DataTransferWarningCode[] = [];
let accountResult: AccountTransferImportResult | null = null;
let configResult: DataTransferConfigImportResult | null = null;
if (options.includeAccounts) {
if (parsed.accounts) {
accountResult = await importAllAccountsFromTransferJson(JSON.stringify(parsed.accounts), {
onProgress: options.onAccountProgress,
});
} else {
warnings.push('accounts_section_missing');
}
}
if (options.includeConfig) {
if (parsed.config) {View on GitHub (pinned to 1ed8b77992)
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.
Example fix
// before
await importDataTransferJson(oldExportJson, options); // version: 1
// after
const parsed = JSON.parse(oldExportJson);
if (parsed.version !== 2) {
parsed.version = 2; // or re-export from the upgraded app
}
await importDataTransferJson(JSON.stringify(parsed), options); Defensive patterns
Strategy: type-guard
Validate before calling
function bundleVersionMatches(parsed, expectedVersion) {
return typeof parsed === 'object' && parsed !== null
&& 'version' in parsed && parsed.version === expectedVersion;
}
const parsed = JSON.parse(json);
if (!bundleVersionMatches(parsed, 2)) { alert('Bundle version mismatch — re-export from the current app version.'); return; } Type guard
function isCurrentBundle(v) {
return typeof v === 'object' && v !== null && 'version' in v && typeof v.version === 'number' && v.version === DATA_TRANSFER_VERSION;
} Try / catch
try {
await importDataTransferJson(json, options);
} catch (e) {
if (e.message === 'invalid_bundle_version') {
const v = JSON.parse(json)?.version;
console.error(`Bundle version ${v} != expected ${DATA_TRANSFER_VERSION}; re-export the data.`);
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- selected_sections_missing
- invalidJsonMessage
- messages.rawLineNoRefreshToken(item.lineNumber)
- messages.rawLineMultipleRefreshTokens(item.lineNumber)
- messages.invalidJson
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/2f648ebe2bda51d9.
Report an issue: GitHub.