jlcodes99/cockpit-tools · error
invalid_bundle_platforms
invalid_bundle_platforms
Error message
invalid_bundle_platforms
What it means
The transfer bundle lacks a valid 'platforms' object. After schema and version checks pass, the importer requires parsed.platforms to be a record mapping platform IDs to payloads; anything else is rejected.
Source
Thrown at src/services/accountTransferService.ts:344
}
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,
exported_data: [],
} as AccountTransferPlatformPayload);
}
return platforms;View on GitHub (pinned to 1ed8b77992)
Solutions
- Add a 'platforms' object keyed by platform ID (may be empty {} if intentional) to the bundle
- Re-export the bundle ensuring at least the platforms wrapper is serialized
- Fix renames like 'platform' back to 'platforms'
- Validate the bundle structure against the AccountTransferBundle type before importing
Example fix
// before
{ "schema": "...", "version": 1 }
// after
{ "schema": "...", "version": 1, "platforms": {} } Defensive patterns
Strategy: validation
Validate before calling
const obj = JSON.parse(text);
if (typeof obj.platforms !== 'object' || obj.platforms === null || Array.isArray(obj.platforms)) {
throw new Error('invalid_bundle_platforms');
} Type guard
function hasPlatforms(v: unknown): v is { platforms: Record<string, unknown> } {
return typeof v === 'object' && v !== null && !Array.isArray(v)
&& typeof (v as any).platforms === 'object' && (v as any).platforms !== null
&& !Array.isArray((v as any).platforms);
} Try / catch
try {
await importBundle(text);
} catch (e) {
if (e instanceof Error && e.message === 'invalid_bundle_platforms') {
alert('Bundle is missing a valid platforms object.');
} else throw e;
} Prevention
- Always include the platforms object in exports, even when empty ({})
- Do not rename platforms to platform or move payloads to the root
- Round-trip exports through the app's importer in tests to catch shape drift
- Validate bundles with a JSON schema before import
When it happens
Trigger: parsed.version matches but isRecord(parsed.platforms) is false — platforms key missing, null, an array, or a non-object value.
Common situations: Bundles exported with no platform data, hand-edited files where platforms was deleted or renamed, exporting an empty selection and serializing it as null.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/5614c0ec76144796.
Report an issue: GitHub.