jlcodes99/cockpit-tools · error

messages.providerMismatch

Error message

messages.providerMismatch

What it means

The bundle object declares a 'provider' string that is non-empty and differs from the platformId currently being imported into. The import is rejected to prevent importing accounts belonging to another platform (line 422), with messages.providerMismatch.

Source

Thrown at src/hooks/useProviderAccountsPage.ts:422

  if (typeof root === 'string') {
    return resolveExternalImportBundleItems(root, platformId, messages);
  }

  if (Array.isArray(root)) {
    if (root.length === 0) {
      throw new Error(messages.noItems);
    }
    return root;
  }

  if (!root || typeof root !== 'object') {
    throw new Error(messages.empty);
  }

  const provider = (root as { provider?: unknown }).provider;
  if (typeof provider === 'string' && provider.trim() && provider.trim() !== platformId) {
    throw new Error(messages.providerMismatch);
  }

  const items = (root as { items?: unknown }).items;
  if (Array.isArray(items) && items.length > 0) {
    return items;
  }

  if (platformId === 'codex' && isCodexDirectImportItem(root)) {
    return [root];
  }

  if (!Array.isArray(items) || items.length === 0) {
    throw new Error(messages.noItems);
  }

  throw new Error(messages.noItems);
};

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Import the file under the matching platform (the one named in provider)
  2. Remove or correct the provider field if the bundle truly belongs to the target platform
  3. Re-export from the correct source tool
  4. If platform ids were renamed, update old exports' provider field to the new id

Example fix

// before (importing into 'mytool')
{"provider":"codex","items":[{"refresh_token":"rt_a"}]}
// after
{"provider":"mytool","items":[{"refresh_token":"rt_a"}]}
Defensive patterns

Strategy: validation

Validate before calling

const bundle = JSON.parse(content) as { provider?: unknown };
if (typeof bundle.provider === 'string' && bundle.provider.trim() && bundle.provider.trim() !== targetPlatformId) {
  throw new Error(`Bundle is for provider '${bundle.provider}', not '${targetPlatformId}'`);
}

Type guard

const providerMatches = (bundle: unknown, platformId: string): boolean => {
  const p = (bundle as { provider?: unknown } | null)?.provider;
  return !(typeof p === 'string' && p.trim() && p.trim() !== platformId);
};

Try / catch

try {
  items = resolveExternalImportBundleItems(content, platformId, messages);
} catch (e) {
  if (e instanceof Error && e.message === messages.providerMismatch) {
    promptSelectCorrectPlatform(e.message);
  }
}

Prevention

When it happens

Trigger: Parsed root is an object with provider set to a string whose trimmed value !== platformId (e.g. provider:'codex' while importing into a different platform).

Common situations: Exporting from one tool and importing into another; renaming a platform id so old exports carry stale provider values; mixing up export files between providers.

Related errors


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