farion1231/cc-switch · error · Error
Claude Desktop official provider was not created
Error message
Claude Desktop official provider was not created
What it means
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.
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
Example fix
// before
await providersApi.ensureClaudeDesktopOfficialProvider();
const providers = await providersApi.getAll(appId);
// after
await providersApi.ensureClaudeDesktopOfficialProvider();
await queryClient.invalidateQueries({ queryKey: ['providers', appId] });
const providers = await providersApi.getAll(appId); Defensive patterns
Strategy: try-catch
Try / catch
try {
await createProvider({
appId: 'claude-desktop',
providerInput: { ensureClaudeDesktopOfficialSeed: true } as ProviderInput,
});
} catch (error) {
if (error instanceof Error && error.message.includes('Claude Desktop official provider')) {
// offer a reload/retry; likely stale cache or seed ID mismatch
} else {
throw error;
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of farion1231/cc-switch@0b5da51016 (2026-08-20).
Data as JSON: /api/errors/74054df4e2ed3a56.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/query/mutations.ts:46
addToLive?: boolean;
ensureClaudeDesktopOfficialSeed?: boolean;
ensureGrokBuildOfficialSeed?: boolean;
},
) => {
const {
providerKey: _providerKey,
addToLive,
ensureClaudeDesktopOfficialSeed,
ensureGrokBuildOfficialSeed,
...rest
} = providerInput;
if (appId === "claude-desktop" && ensureClaudeDesktopOfficialSeed) {
await providersApi.ensureClaudeDesktopOfficialProvider();
const providers = await providersApi.getAll(appId);
const officialProvider = providers["claude-desktop-official"];
if (!officialProvider) {
throw new Error("Claude Desktop official provider was not created");
}
return officialProvider;
}
if (appId === "grokbuild" && ensureGrokBuildOfficialSeed) {
await providersApi.ensureGrokBuildOfficialProvider();
const providers = await providersApi.getAll(appId);
const officialProvider = providers[GROKBUILD_OFFICIAL_PROVIDER_ID];
if (!officialProvider) {
throw new Error("Grok Build official provider was not created");
}
return officialProvider;
}
let id: string;
if (
appId === "opencode" ||View on GitHub (pinned to 0b5da51016)