{"record":{"id":"9990ed3751effe8c","repo":"jlcodes99/cockpit-tools","slug":"instances-quota-accountmissing","errorCode":"instances.quota.accountMissing","errorMessage":"账号不存在","messagePattern":"账号不存在","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pages/useCodexAccountsAccessController.tsx","lineNumber":1018,"sourceCode":"      setCliLaunchModal((prev) =>\n        prev\n          ? {\n              ...prev,\n              workingDir,\n              workingDirError: null,\n              preparing: true,\n              copied: false,\n              executeMessage: null,\n              executeError: null,\n            }\n          : prev,\n      );\n      try {\n        if (\n          modal.target === \"account\" &&\n          !accounts.some((item) => item.id === modal.accountId)\n        ) {\n          throw new Error(t(\"instances.quota.accountMissing\", \"账号不存在\"));\n        }\n        const { instanceId, draft } = await buildCodexCliInstanceDraft(\n          modal,\n          workingDir,\n        );\n        const launchInfo =\n          await codexInstanceService.previewCodexInstanceLaunchCommand({\n            userDataDir: draft.userDataDir,\n            workingDir: draft.workingDir,\n            extraArgs: draft.extraArgs,\n            terminal: selectedTerminal,\n          });\n        persistLastCodexCliWorkingDir(workingDir);\n        const next: CodexCliLaunchModalState = {\n          ...modal,\n          instanceId,\n          instanceDraft: draft,\n          instanceName: draft.name,","sourceCodeStart":1000,"sourceCodeEnd":1036,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/pages/useCodexAccountsAccessController.tsx#L1000-L1036","documentation":"prepareCodexCliLaunch builds the payload for launching the Codex CLI from the open modal. When modal.target === 'account' it first verifies that modal.accountId exists in the loaded accounts list; if not, it throws a localized 'instances.quota.accountMissing' (账号不存在, 'account does not exist'). This prevents launching against a stale or deleted account.","triggerScenarios":"Opening the Codex CLI launch modal with target='account' and an accountId that is not present in the accounts array — called by openCodexAccountsAccessController paths: openCodexCliLaunchModal, handleChooseCodexCliWorkingDir, or the prepared flow.","commonSituations":"The account was deleted (or the provider account list refreshed/filtered) while the modal was still open; a stale accountId persisted from a previous session; accounts still loading so the list is empty when the check runs.","solutions":["Close and reopen the launch modal so it binds to a currently existing account.","Refresh the accounts list and re-select the target account before launching.","If launching programmatically, verify accounts.some(a => a.id === accountId) before opening the modal, and fall back to target='instance' or prompt the user to pick an account.","If accounts may still be loading, await the accounts query completion before calling prepareCodexCliLaunch."],"exampleFix":"// before\nopenCodexCliLaunchModal({ target: 'account', accountId: staleId, ... });\n// after\nif (!accounts.some((item) => item.id === accountId)) {\n  toast.error(t('instances.quota.accountMissing'));\n  return;\n}\nopenCodexCliLaunchModal({ target: 'account', accountId, ... });","handlingStrategy":"validation","validationCode":"const accountExists = (accounts, accountId) =>\n  modal.target !== 'account' || accounts.some((item) => item.id === accountId);\nif (!accountExists(accounts, modal.accountId)) {\n  toast.error(t('instances.quota.accountMissing'));\n  return;\n}","typeGuard":"const isKnownAccount = (\n  accounts: { id: string }[],\n  accountId?: string | null,\n): accountId is string =>\n  typeof accountId === 'string' && accounts.some((a) => a.id === accountId);","tryCatchPattern":"try {\n  await prepareCodexCliLaunch(modal, workingDir);\n} catch (e) {\n  if (String(e).includes('instances.quota.accountMissing')) {\n    toast.error(t('instances.quota.accountMissing'));\n    closeLaunchModal();\n    await refetchAccounts();\n  } else throw e;\n}","preventionTips":["Revalidate the selected accountId against the accounts list right before opening the modal","Invalidate/close stale launch modals whenever the accounts list changes or is refetched","Disable the launch action while accounts are still loading","Persist selection by a re-verified id, not a stale modal snapshot"],"tags":["account-state","stale-reference","codex-cli","localization"],"backgroundTag":"account-not-found","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}