{"record":{"id":"d3a3d76897d3341b","repo":"openai/codex-plugin-cc","slug":"missing-broker-endpoint","errorCode":null,"errorMessage":"Missing broker endpoint.","messagePattern":"Missing broker endpoint\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/codex/scripts/lib/broker-endpoint.mjs","lineNumber":21,"sourceCode":"\nfunction sanitizePipeName(value) {\n  return String(value ?? \"\")\n    .replace(/[^A-Za-z0-9._-]/g, \"-\")\n    .replace(/^-+|-+$/g, \"\");\n}\n\nexport function createBrokerEndpoint(sessionDir, platform = process.platform) {\n  if (platform === \"win32\") {\n    const pipeName = sanitizePipeName(`${path.win32.basename(sessionDir)}-codex-app-server`);\n    return `pipe:\\\\\\\\.\\\\pipe\\\\${pipeName}`;\n  }\n\n  return `unix:${path.join(sessionDir, \"broker.sock\")}`;\n}\n\nexport function parseBrokerEndpoint(endpoint) {\n  if (typeof endpoint !== \"string\" || endpoint.length === 0) {\n    throw new Error(\"Missing broker endpoint.\");\n  }\n\n  if (endpoint.startsWith(\"pipe:\")) {\n    const pipePath = endpoint.slice(\"pipe:\".length);\n    if (!pipePath) {\n      throw new Error(\"Broker pipe endpoint is missing its path.\");\n    }\n    return { kind: \"pipe\", path: pipePath };\n  }\n\n  if (endpoint.startsWith(\"unix:\")) {\n    const socketPath = endpoint.slice(\"unix:\".length);\n    if (!socketPath) {\n      throw new Error(\"Broker Unix socket endpoint is missing its path.\");\n    }\n    return { kind: \"unix\", path: socketPath };\n  }\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/openai/codex-plugin-cc/blob/db52e28f4d9ded852ab3942cea316258ae4ef346/plugins/codex/scripts/lib/broker-endpoint.mjs#L3-L39","documentation":"Thrown by parseBrokerEndpoint when the endpoint argument is not a non-empty string. parseBrokerEndpoint is the inverse of createBrokerEndpoint: it decodes a 'pipe:' or 'unix:' URI back into {kind, path}. A missing/empty endpoint means the broker session configuration was never written or was corrupted, so no transport can be selected.","triggerScenarios":"Calling parseBrokerEndpoint(undefined), parseBrokerEndpoint(''), or parseBrokerEndpoint(null). This happens when the CODEX broker endpoint env var is unset, loadBrokerSession(cwd) returned null, and a caller forwarded that null/empty value into the parser instead of falling back to createBrokerEndpoint.","commonSituations":"First run in a fresh session dir before any broker.sock was created. An env var (e.g. BROKER_ENDPOINT_ENV) was cleared or never exported. A stale config file pointed to an endpoint that got overwritten with empty. Cross-platform code passing a win32 pipe on a unix host or vice-versa without normalizing first.","solutions":["Ensure createBrokerEndpoint(sessionDir) ran and its return value was stored/passed to parseBrokerEndpoint.","Set the broker endpoint env var to a valid 'unix:/path/to/broker.sock' or 'pipe:\\\\.\\pipe\\name' string before parsing.","Guard the caller: if endpoint is falsy, call createBrokerEndpoint(cwd) to synthesize one rather than parsing.","Check that loadBrokerSession(cwd) actually wrote the session file and that it contains the endpoint field."],"exampleFix":"// before\nconst transport = parseBrokerEndpoint(loadedEndpoint) // loadedEndpoint is undefined -> throws\n\n// after\nconst endpoint = loadedEndpoint || createBrokerEndpoint(sessionDir)\nconst transport = parseBrokerEndpoint(endpoint)","handlingStrategy":"validation","validationCode":"import { createBrokerEndpoint } from './broker-endpoint.mjs';\n\nfunction safeParseBrokerEndpoint(endpoint, sessionDir, platform) {\n  if (typeof endpoint !== 'string' || endpoint.length === 0) {\n    // synthesize a fresh endpoint instead of throwing\n    endpoint = createBrokerEndpoint(sessionDir, platform);\n  }\n  return parseBrokerEndpoint(endpoint);\n}","typeGuard":"function isBrokerEndpointString(v) {\n  return typeof v === 'string' && v.length > 0 && (v.startsWith('unix:') || v.startsWith('pipe:'));\n}","tryCatchPattern":"null","preventionTips":["Always persist the endpoint from createBrokerEndpoint and reload it before parsing.","Guard callers: fall back to createBrokerEndpoint when the loaded endpoint is falsy.","Export/inherit the broker endpoint env var across subprocess boundaries.","Write the broker session file atomically so partial/empty writes cannot be read."],"tags":["broker","transport","config","validation"],"backgroundTag":null,"analyzedSha":"db52e28f4d9ded852ab3942cea316258ae4ef346","analyzedAt":"2026-08-13T05:13:20.855Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}