{"record":{"id":"74054df4e2ed3a56","repo":"farion1231/cc-switch","slug":"claude-desktop-official-provider-was-not-created","errorCode":null,"errorMessage":"Claude Desktop official provider was not created","messagePattern":"Claude Desktop official provider was not created","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/query/mutations.ts","lineNumber":46,"sourceCode":"        addToLive?: boolean;\n        ensureClaudeDesktopOfficialSeed?: boolean;\n        ensureGrokBuildOfficialSeed?: boolean;\n      },\n    ) => {\n      const {\n        providerKey: _providerKey,\n        addToLive,\n        ensureClaudeDesktopOfficialSeed,\n        ensureGrokBuildOfficialSeed,\n        ...rest\n      } = providerInput;\n\n      if (appId === \"claude-desktop\" && ensureClaudeDesktopOfficialSeed) {\n        await providersApi.ensureClaudeDesktopOfficialProvider();\n        const providers = await providersApi.getAll(appId);\n        const officialProvider = providers[\"claude-desktop-official\"];\n        if (!officialProvider) {\n          throw new Error(\"Claude Desktop official provider was not created\");\n        }\n        return officialProvider;\n      }\n\n      if (appId === \"grokbuild\" && ensureGrokBuildOfficialSeed) {\n        await providersApi.ensureGrokBuildOfficialProvider();\n        const providers = await providersApi.getAll(appId);\n        const officialProvider = providers[GROKBUILD_OFFICIAL_PROVIDER_ID];\n        if (!officialProvider) {\n          throw new Error(\"Grok Build official provider was not created\");\n        }\n        return officialProvider;\n      }\n\n      let id: string;\n\n      if (\n        appId === \"opencode\" ||","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/farion1231/cc-switch/blob/0b5da510168914b251481654a568c3ffacd62cf4/src/lib/query/mutations.ts#L28-L64","documentation":"In the createProvider mutation, when appId === 'claude-desktop' and ensureClaudeDesktopOfficialSeed is set, the code calls providersApi.ensureClaudeDesktopOfficialProvider(), re-reads all providers, and expects the entry keyed 'claude-desktop-official'. This error means the seed command returned without error yet the expected record is absent from the providers map — an invariant violation, not a user-input problem.","triggerScenarios":"ensureClaudeDesktopOfficialProvider() resolves but providersApi.getAll('claude-desktop') returns a map without the 'claude-desktop-official' key — e.g. the backend seeds a different ID, the write was rolled back, or a stale query cache was read.","commonSituations":"Backend seed command renamed the provider ID; persisted provider store reset concurrently between write and read; react-query cache not invalidated after the seed mutation.","solutions":["Inspect the persisted providers for the claude-desktop app and confirm the exact key is 'claude-desktop-official'","Check the backend ensureClaudeDesktopOfficialProvider implementation — the ID and app filter must match what getAll returns","Invalidate/refetch the providers query after the seed call before reading it"],"exampleFix":"// before\nawait providersApi.ensureClaudeDesktopOfficialProvider();\nconst providers = await providersApi.getAll(appId);\n\n// after\nawait providersApi.ensureClaudeDesktopOfficialProvider();\nawait queryClient.invalidateQueries({ queryKey: ['providers', appId] });\nconst providers = await providersApi.getAll(appId);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await createProvider({\n    appId: 'claude-desktop',\n    providerInput: { ensureClaudeDesktopOfficialSeed: true } as ProviderInput,\n  });\n} catch (error) {\n  if (error instanceof Error && error.message.includes('Claude Desktop official provider')) {\n    // offer a reload/retry; likely stale cache or seed ID mismatch\n  } else {\n    throw error;\n  }\n}","preventionTips":["Invalidate the providers query between the seed call and the verification read","Keep the 'claude-desktop-official' ID as a shared constant across front/back ends","Log the full provider map when the invariant fails to make diagnosis immediate"],"tags":["providers","seed","invariant","claude-desktop","react-query"],"backgroundTag":"missing-seed-data","analyzedSha":"0b5da510168914b251481654a568c3ffacd62cf4","analyzedAt":"2026-08-20T14:29:00.113Z","contentChangedAt":"2026-08-20T14:29:00.113Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}