farion1231/cc-switch · error · Error

Grok Build official provider was not created

Error message

Grok Build official provider was not created

What it means

The grokbuild twin of the Claude Desktop seed check: when appId === 'grokbuild' and ensureGrokBuildOfficialSeed is set, the mutation calls providersApi.ensureGrokBuildOfficialProvider(), re-reads all providers, and requires the entry keyed by GROKBUILD_OFFICIAL_PROVIDER_ID. The throw means the seed command completed but the official provider record still is not in the returned map.

Solutions

  1. Inspect the persisted grokbuild providers and verify the record's ID equals GROKBUILD_OFFICIAL_PROVIDER_ID
  2. Align the backend ensure command's written ID with the frontend constant (and migrate old records if it changed)
  3. Invalidate the providers query after seeding before the verification read

Example fix

// before
await providersApi.ensureGrokBuildOfficialProvider();
const providers = await providersApi.getAll(appId);

// after
await providersApi.ensureGrokBuildOfficialProvider();
await queryClient.invalidateQueries({ queryKey: ['providers', appId] });
const providers = await providersApi.getAll(appId);
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await createProvider({
    appId: 'grokbuild',
    providerInput: { ensureGrokBuildOfficialSeed: true } as ProviderInput,
  });
} catch (error) {
  if (error instanceof Error && error.message.includes('Grok Build official provider')) {
    // reload providers and retry once; inspect persisted store if it repeats
  } else {
    throw error;
  }
}

Prevention

When it happens

Trigger: ensureGrokBuildOfficialProvider() resolves but providersApi.getAll('grokbuild') has no entry under GROKBUILD_OFFICIAL_PROVIDER_ID — mismatched constant vs persisted ID, rolled-back write, or stale cached read.

Common situations: GROKBUILD_OFFICIAL_PROVIDER_ID constant changed without migrating stored data; backend seed filters by a different appId; query cache serving pre-seed data.

Related errors


AI-assisted analysis of farion1231/cc-switch@0b5da51016 (2026-08-20). Data as JSON: /api/errors/32fdfd821c6e162f. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/query/mutations.ts:56

        ...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" ||
        appId === "openclaw" ||
        appId === "hermes" ||
        appId === "pi"
      ) {
        if (
          providerInput.category === "omo" ||
          providerInput.category === "omo-slim"
        ) {
          const prefix = providerInput.category === "omo" ? "omo" : "omo-slim";
          id = `${prefix}-${generateUUID()}`;

View on GitHub (pinned to 0b5da51016)