{"record":{"id":"99406a9fc45013dc","repo":"jlcodes99/cockpit-tools","slug":"messages-providermismatch","errorCode":null,"errorMessage":"messages.providerMismatch","messagePattern":"messages\\.providerMismatch","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/useProviderAccountsPage.ts","lineNumber":422,"sourceCode":"\n  if (typeof root === 'string') {\n    return resolveExternalImportBundleItems(root, platformId, messages);\n  }\n\n  if (Array.isArray(root)) {\n    if (root.length === 0) {\n      throw new Error(messages.noItems);\n    }\n    return root;\n  }\n\n  if (!root || typeof root !== 'object') {\n    throw new Error(messages.empty);\n  }\n\n  const provider = (root as { provider?: unknown }).provider;\n  if (typeof provider === 'string' && provider.trim() && provider.trim() !== platformId) {\n    throw new Error(messages.providerMismatch);\n  }\n\n  const items = (root as { items?: unknown }).items;\n  if (Array.isArray(items) && items.length > 0) {\n    return items;\n  }\n\n  if (platformId === 'codex' && isCodexDirectImportItem(root)) {\n    return [root];\n  }\n\n  if (!Array.isArray(items) || items.length === 0) {\n    throw new Error(messages.noItems);\n  }\n\n  throw new Error(messages.noItems);\n};\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/hooks/useProviderAccountsPage.ts#L404-L440","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Import the file under the matching platform (the one named in provider)","Remove or correct the provider field if the bundle truly belongs to the target platform","Re-export from the correct source tool","If platform ids were renamed, update old exports' provider field to the new id"],"exampleFix":"// before (importing into 'mytool')\n{\"provider\":\"codex\",\"items\":[{\"refresh_token\":\"rt_a\"}]}\n// after\n{\"provider\":\"mytool\",\"items\":[{\"refresh_token\":\"rt_a\"}]}","handlingStrategy":"validation","validationCode":"const bundle = JSON.parse(content) as { provider?: unknown };\nif (typeof bundle.provider === 'string' && bundle.provider.trim() && bundle.provider.trim() !== targetPlatformId) {\n  throw new Error(`Bundle is for provider '${bundle.provider}', not '${targetPlatformId}'`);\n}","typeGuard":"const providerMatches = (bundle: unknown, platformId: string): boolean => {\n  const p = (bundle as { provider?: unknown } | null)?.provider;\n  return !(typeof p === 'string' && p.trim() && p.trim() !== platformId);\n};","tryCatchPattern":"try {\n  items = resolveExternalImportBundleItems(content, platformId, messages);\n} catch (e) {\n  if (e instanceof Error && e.message === messages.providerMismatch) {\n    promptSelectCorrectPlatform(e.message);\n  }\n}","preventionTips":["Match the import target platform to the export's provider field","Keep separate export files per provider and label them clearly","Update provider fields in old exports after platform id renames"],"tags":["import","provider-mismatch","validation","config"],"backgroundTag":"provider-mismatch","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}