jlcodes99/cockpit-tools · error

invalid_bundle_schema

invalid_bundle_schema

Error message

invalid_bundle_schema

What it means

Sentinel error in parseAccountTransferBundle: the transfer JSON parsed and has a valid root object, but its schema field does not match ACCOUNT_TRANSFER_SCHEMA. It fires when importing an account-transfer bundle exported by an incompatible version of the app, so the payload layout cannot be trusted and the import is rejected outright.

Solutions

  1. Check the bundle's schema field and set it to the value of ACCOUNT_TRANSFER_SCHEMA in this build
  2. Re-export the bundle from the same application version
  3. If the schema genuinely differs, write a converter to map the foreign schema to this one before import
  4. Verify no find-and-replace or editor tooling stripped or renamed the schema field

Example fix

// before
{ "schema": "my-bundle", "version": 1, ... }
// after
{ "schema": "<ACCOUNT_TRANSFER_SCHEMA value>", "version": 1, ... }
Defensive patterns

Strategy: validation

Validate before calling

const obj = JSON.parse(text);
if (obj.schema !== ACCOUNT_TRANSFER_SCHEMA) throw new Error('invalid_bundle_schema');

Type guard

function hasValidSchema(v: Record<string, unknown>, expected: unknown): boolean {
  return v.schema === expected;
}

Try / catch

try {
  await importBundle(text);
} catch (e) {
  if (e instanceof Error && e.message === 'invalid_bundle_schema') {
    alert('Bundle schema mismatch — re-export from this application.');
  } else throw e;
}

Prevention

When it happens

Trigger: parsed is a record but parsed.schema !== ACCOUNT_TRANSFER_SCHEMA — missing, misspelled, or from another schema family.

Common situations: Importing a bundle exported by another application, editing or deleting the schema field by hand, copying an example bundle with placeholder schema values.

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/1a54658491140d7f. Report an issue: GitHub.

Appendix: source

Thrown at src/services/accountTransferService.ts:335

      account_count: accountCount,
    },
    platforms,
  };
}

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]);

View on GitHub (pinned to 1ed8b77992)