jlcodes99/cockpit-tools · error

codex.switchAuth.reauthGenerationMissing

codex.switchAuth.reauthGenerationMissing

Error message

codex.switchAuth.reauthGenerationMissing

What it means

Type guard in the continue-switch-after-reauth path: after OAuth re-auth succeeds, the refreshed account's token_generation is read from the account store; if it is not a number (undefined/null), the code cannot verify the credential generation and aborts the switch instead of using a stale token. The throw corresponds to the codex.switchAuth.reauthGenerationMissing key.

Source

Thrown at src/pages/useCodexAccountsOAuthController.ts:1262

        if (reauthRetrySwitchAccountId && account?.id) {
          setAddStatus("loading");
          setAddMessage(
            t(
              "codex.switchAuth.switchingAfterReauth",
              "授权成功,正在继续切换账号...",
            ),
          );
          try {
            const refreshedAccount =
              useCodexAccountStore
                .getState()
                .accounts.find((item) => item.id === account.id) || account;
            const tokenGeneration = refreshedAccount.token_generation;
            if (
              typeof tokenGeneration !== "number" ||
              !Number.isFinite(tokenGeneration)
            ) {
              throw new Error(t("codex.switchAuth.reauthGenerationMissing"));
            }
            await useCodexAccountStore.getState().switchAccount(account.id, {
              reauthTokenGeneration: tokenGeneration,
              reconcileAfterSwitch: true,
              launchAfterSwitch: reauthRetryLaunchAfterSwitch,
            });
          } catch (error) {
            setAddStatus("error");
            setAddMessage(
              t("codex.switchAuth.switchAfterReauthFailed", {
                defaultValue: "授权已更新,但继续切换失败:{{error}}",
                error: String(error).replace(/^Error:\s*/, ""),
              }),
            );
            return;
          }
        }
        if (reauthRetryInstanceId && account?.id) {

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Wait for the account store to refresh so the new token_generation lands before continuing the switch
  2. Re-run the re-auth flow if credentials were written without a generation bump
  3. Inspect why the post-reauth account record lacks token_generation (backend write failure)
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/pages/useCodexAccountsOAuthController.ts:1262 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/e795cd67776e29e9. Report an issue: GitHub.