jlcodes99/cockpit-tools · error
codex.localAccess.noEligibleAccountsSelected
codex.localAccess.noEligibleAccountsSelected
Error message
所选账号不在当前环境中,或不符合 API 服务条件。请先在当前环境导入可用 Codex 账号后再添加。
What it means
Before saving Codex API-service local-access membership, the page filters the selected accountIds through resolveLocalAccessEligibility (respecting the current environment and restrictFreeAccounts). If the user selected at least one account but NONE survive filtering, it throws an Error with the message 'codex.localAccess.noEligibleAccountsSelected' — i.e. none of the chosen accounts actually qualify for the API service in this environment.
Source
Thrown at src/pages/CodexApiServicePage.tsx:2063
const saveMembers = async (
accountIds: string[],
restrictFreeAccounts: boolean,
backupAccountIds?: string[],
preferredAccountIds?: string[],
imageGenerationAccountPolicies?: Record<string, CodexLocalAccessImageGenerationPolicy>,
) => {
const filteredAccountIds =
accountIds.length === 0
? []
: filterCodexLocalAccessAccountIds(
accountIds,
accounts,
restrictFreeAccounts,
);
if (accountIds.length > 0 && filteredAccountIds.length === 0) {
throw new Error(
t(
"codex.localAccess.noEligibleAccountsSelected",
"所选账号不在当前环境中,或不符合 API 服务条件。请先在当前环境导入可用 Codex 账号后再添加。",
),
);
}
const filteredAccountIdSet = new Set(filteredAccountIds);
const nextBackupAccountIds = (backupAccountIds ?? []).filter((id) =>
filteredAccountIdSet.has(id),
);
const nextPreferredAccountIds = (preferredAccountIds ?? []).filter((id) =>
filteredAccountIdSet.has(id),
);
const next = await codexLocalAccessService.saveCodexLocalAccessAccounts(
filteredAccountIds,
restrictFreeAccounts,View on GitHub (pinned to 1ed8b77992)
Solutions
- Re-select accounts that are actually present in the current environment and eligible for the API service.
- Import usable Codex accounts into the current environment before adding them to the API service set.
- Disable ineligible accounts in the picker (filter client-side with the same eligibility rules) so they cannot be selected.
- Check the restrictFreeAccounts setting — deselect free accounts or lift the restriction if intended.
Example fix
// before
await saveLocalAccess({ accountIds: selectedIds });
// after
const eligible = filterEligibleAccountIds(selectedIds, accounts, restrictFreeAccounts);
if (selectedIds.length > 0 && eligible.length === 0) {
showError(t('codex.localAccess.noEligibleAccountsSelected'));
return;
}
await saveLocalAccess({ accountIds: eligible }); Defensive patterns
Strategy: validation
Validate before calling
const eligible = filterEligibleLocalAccessAccountIds(accountIds, accounts, restrictFreeAccounts);
if (accountIds.length > 0 && eligible.length === 0) {
return { ok: false, reason: 'noEligibleAccountsSelected' };
} Try / catch
try {
await saveLocalAccess({ accountIds });
} catch (e) {
if (String(e).includes('noEligibleAccountsSelected')) {
notify(t('codex.localAccess.noEligibleAccountsSelected'));
return;
}
throw e;
} Prevention
- Filter picker options with the same eligibility rules used at save time.
- Re-validate persisted selections when the environment or restrictFreeAccounts changes.
- Clear selections that reference accounts no longer present in the current environment.
When it happens
Trigger: Clicking save/add on the Codex API service page with a non-empty accountIds selection where every selected account was removed by the eligibility filter (accounts not in the current environment, or free accounts while restrictFreeAccounts is true).
Common situations: Stale UI selection referencing accounts that were deleted or belong to another environment/profile; switching environments while a selection persisted; free-tier Codex accounts selected while free accounts are restricted from API service.
Related errors
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/702e9ace0668cdbe.
Report an issue: GitHub.