farion1231/cc-switch · error · Error
Codex current-login provider was not created
Error message
Codex current-login provider was not created
What it means
Thrown inside useAddProviderMutation's mutationFn on the Codex native-login path: when appId is 'codex', ensureCodexOfficialSeed is set, and no managed 'codex_oauth' account id can be resolved, the code calls ensureCodexOfficialProvider() and then expects providers[CODEX_OFFICIAL_PROVIDER_ID] to exist. Its absence means the official seed did not land - an invariant break, not a user-input error.
Source
Thrown at src/lib/query/mutations.ts:70
throw new Error("Claude Desktop official provider was not created");
}
return officialProvider;
}
if (appId === "codex" && ensureCodexOfficialSeed) {
// The fixed seed is the one native "Codex current login" card.
// A managed account gets its own provider row so several accounts can
// coexist without replacing that native-login entry.
const managedAccountId = resolveManagedAccountId(
rest.meta,
"codex_oauth",
)?.trim();
if (!managedAccountId) {
await providersApi.ensureCodexOfficialProvider();
const providers = await providersApi.getAll(appId);
const nativeLoginProvider = providers[CODEX_OFFICIAL_PROVIDER_ID];
if (!nativeLoginProvider) {
throw new Error("Codex current-login provider was not created");
}
return nativeLoginProvider;
}
const managedOfficialProvider: Provider = {
...rest,
id: generateUUID(),
category: "official",
createdAt: Date.now(),
};
await providersApi.add(managedOfficialProvider, appId, addToLive);
return managedOfficialProvider;
}
if (appId === "grokbuild" && ensureGrokBuildOfficialSeed) {
await providersApi.ensureGrokBuildOfficialProvider();
const providers = await providersApi.getAll(appId);
const officialProvider = providers[GROKBUILD_OFFICIAL_PROVIDER_ID];View on GitHub (pinned to a2e22f3302)
Solutions
- Verify the Codex config/auth files the ensure command seeds from actually exist and are readable
- Retry the mutation once to rule out a read-after-write race
- Log the Object.keys() of getAll('codex') when the invariant fails to see what was actually returned
Example fix
// before
await providersApi.ensureCodexOfficialProvider();
const native = (await providersApi.getAll(appId))[CODEX_OFFICIAL_PROVIDER_ID];
if (!native) throw new Error("Codex current-login provider was not created");
// after
await providersApi.ensureCodexOfficialProvider();
let native: Provider | undefined;
for (let i = 0; i < 3 && !native; i++) {
await new Promise((r) => setTimeout(r, 100 * (i + 1)));
native = (await providersApi.getAll(appId))[CODEX_OFFICIAL_PROVIDER_ID];
}
if (!native) throw new Error("Codex current-login provider was not created"); Defensive patterns
Strategy: retry
Validate before calling
// Skip the ensure path when the native-login card already exists
const existing = (await providersApi.getAll("codex"))[CODEX_OFFICIAL_PROVIDER_ID];
if (existing) {
return existing;
} Try / catch
try {
return await addProvider.mutateAsync(input);
} catch (e) {
if (e instanceof Error && e.message === "Codex current-login provider was not created") {
await queryClient.invalidateQueries({ queryKey: providersKeys.all });
return await addProvider.mutateAsync(input); // one retry after cache refresh
}
throw e;
} Prevention
- Verify the Codex CLI auth/config files exist before first-run seeding
- Invalidate and re-read the provider query before declaring the seed failed
- Treat this error as a backend invariant break, not a form validation issue
When it happens
Trigger: mutateAsync({ appId: 'codex', providerInput: { ensureCodexOfficialSeed: true, meta without a codex_oauth managed id } }) where the ensure command no-ops or the subsequent getAll is missing the CODEX_OFFICIAL_PROVIDER_ID key.
Common situations: Fresh install where the Codex CLI auth/config file is missing so the seed cannot be written; backend version older than the frontend seed constant; race between ensure and the provider list read.
Related errors
- Claude Desktop official provider was not created
- Grok Build official provider was not created
- Provider key is required for ${appId}
- jsonEditor.mustBeObject
AI-assisted analysis of farion1231/cc-switch@a2e22f3302 (2026-08-16).
Data as JSON: /api/errors/6280e96e9547abfe.
Report an issue: GitHub.