{"record":{"id":"14c0c412148e07ed","repo":"jlcodes99/cockpit-tools","slug":"failed-to-resolve-codex-api-service-current-marker","errorCode":null,"errorMessage":"Failed to resolve Codex API service current marker:","messagePattern":"Failed to resolve Codex API service current marker:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/pages/useCodexAccountsBaseController.tsx","lineNumber":1223,"sourceCode":"          }\n        } catch {\n          // ignore migration failures\n        }\n        setHideRelayQuota(hide);\n      } catch (error) {\n        console.error(\"Failed to load codex hide-relay-quota preference:\", error);\n      }\n    }, []);\n  \n    const reloadLocalAccessLaunchCurrent = useCallback(async () => {\n      try {\n        const instances = await codexInstanceService.listInstances();\n        const defaultInstance = instances.find((instance) => instance.isDefault);\n        setLocalAccessLaunchCurrent(\n          defaultInstance?.bindAccountId === CODEX_API_SERVICE_BIND_ID,\n        );\n      } catch (error) {\n        console.warn(\n          \"Failed to resolve Codex API service current marker:\",\n          error,\n        );\n      }\n    }, []);\n  \n    const exportFormatOptions = useMemo<SingleSelectFilterOption[]>(\n      () => [\n        {\n          value: \"cockpit_tools\",\n          label: t(\"codex.exportFormat.cockpitTools\", \"Cockpit Tools\"),\n        },\n        {\n          value: \"auth_json\",\n          label: t(\"codex.exportFormat.authJson\", \"auth.json\"),\n        },\n        {\n          value: \"sub2api\",","sourceCodeStart":1205,"sourceCodeEnd":1241,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/pages/useCodexAccountsBaseController.tsx#L1205-L1241","documentation":"A console.warn (not a throw) in useCodexAccountsBaseController when resolving whether the 'Codex API service' default instance is currently bound. The effect calls codexInstanceService.listInstances(); if that fails, the local 'current marker' UI flag is left unset and the failure is only logged.","triggerScenarios":"codexInstanceService.listInstances() rejects — backend instance registry unavailable, IPC invoke error, corrupted/missing instance config, or the effect runs while the backend has not finished initializing.","commonSituations":"App startup race where the instances backend isn't ready; user opened the local access/API-service panel before login/backend startup completed; instance list file corrupted after an abnormal shutdown.","solutions":["Retry opening the panel — the flag is recomputed on the next effect run.","Verify the Codex instance registry (list instances manually) and confirm a default instance exists.","Check backend/IPC logs for the listInstances failure reason.","Restart the backend service or app so instance state is reloaded cleanly.","Re-set the default Codex instance binding if isDefault/bindAccountId state is inconsistent."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const instances = await codexInstanceService.listInstances().catch(() => []);\nif (!instances.length) return; // skip marker resolution","typeGuard":null,"tryCatchPattern":"try {\n  const instances = await codexInstanceService.listInstances();\n  const def = instances.find(i => i.isDefault);\n  setLocalAccessLaunchCurrent(def?.bindAccountId === CODEX_API_SERVICE_BIND_ID);\n} catch (e) {\n  console.warn('Failed to resolve Codex API service current marker:', e);\n  setLocalAccessLaunchCurrent(false);\n}","preventionTips":["Gate the effect on backend-ready state so listInstances isn't called before initialization.","Provide a sensible default for the marker (false) on failure instead of leaving stale UI state.","Log the underlying error detail, not just the wrapper message."],"tags":["ipc","startup-race","codex","ui-state"],"backgroundTag":"backend-list-instances-failed","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"}