{"record":{"id":"6295ba209890c723","repo":"Yeachan-Heo/oh-my-codex","slug":"invalid-detached-leader-authority-target","errorCode":null,"errorMessage":"invalid detached leader authority target","messagePattern":"invalid detached leader authority target","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/index.ts","lineNumber":1510,"sourceCode":"  sessionName: string;\n  sessionId: string;\n  sessionCreated: string;\n  windowId: string;\n  windowIndex: string;\n  ownerId: string;\n};\n\ntype DetachedHudAuthority = {\n  paneId: string;\n  panePid: number;\n  sessionId: string;\n  sessionCreated?: string;\n  windowId: string;\n  operationMarker: string;\n};\n\nfunction captureDetachedLeaderAuthority(leaderPaneId: string, expectedSessionName: string, ownerId: string): DetachedLeaderAuthority {\n  if (!/^%[0-9]+$/.test(leaderPaneId) || !ownerId) throw new Error(\"invalid detached leader authority target\");\n  const output = execTmuxFileSync([\n    \"display-message\", \"-p\", \"-t\", leaderPaneId,\n    \"#{session_name}\\t#{session_id}\\t#{session_created}\\t#{window_index}\\t#{window_id}\\t#{pane_id}\\t#{pane_pid}\",\n  ], { encoding: \"utf-8\", stdio: [\"ignore\", \"pipe\", \"ignore\"] }).trim();\n  const fields = output.split(\"\\t\");\n  if (fields.length !== 7) throw new Error(\"malformed detached leader authority\");\n  const [sessionName, sessionId, sessionCreated, windowIndex, windowId, paneId, panePid] = fields;\n  if (sessionName !== expectedSessionName || paneId !== leaderPaneId || !/^\\$[0-9]+$/.test(sessionId)\n    || !/^[0-9]+$/.test(sessionCreated) || !/^[0-9]+$/.test(windowIndex)\n    || !/^@[0-9]+$/.test(windowId) || !/^[1-9][0-9]*$/.test(panePid)) {\n    throw new Error(\"malformed detached leader authority\");\n  }\n  const parsedPid = Number(panePid);\n  if (!Number.isSafeInteger(parsedPid) || parsedPid <= 0) throw new Error(\"malformed detached leader authority\");\n  return { paneId, panePid: parsedPid, sessionName, sessionId, sessionCreated, windowId, windowIndex, ownerId };\n}\n\n/** Internal detached-launch seam. Exported solely for deterministic CLI tests. */","sourceCodeStart":1492,"sourceCodeEnd":1528,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L1492-L1528","documentation":"captureDetachedLeaderAuthority validates its inputs before querying tmux: leaderPaneId must match tmux pane id format `%<digits>` and ownerId must be non-empty. Malformed args indicate caller corruption or bad upstream data.","triggerScenarios":"Calling captureDetachedLeaderAuthority with a pane id lacking the `%` prefix (e.g. `123`), an empty string, or an empty ownerId.","commonSituations":"Parsing tmux output that changed format; passing a window id (@N) instead of pane id; internal refactors dropping ownerId.","solutions":["Pass the pane id exactly as tmux reports it (%0, %1, ...)","Ensure ownerId is a non-empty session/owner identifier","Log inputs upstream to find where the malformed id originates"],"exampleFix":"// before\ncaptureDetachedLeaderAuthority(\"3\", sessionName, \"\");\n// after\ncaptureDetachedLeaderAuthority(\"%3\", sessionName, ownerId);","handlingStrategy":"type-guard","validationCode":"if (!/^%[0-9]+$/.test(leaderPaneId) || !ownerId) throw new Error('invalid target');","typeGuard":"const isTmuxPaneId = (v: string): v is `%${number}` => /^%[0-9]+$/.test(v);","tryCatchPattern":null,"preventionTips":["Pass pane ids straight from tmux list-panes format output","Never strip the % prefix"],"tags":["tmux","validation","internal-api","pane-id"],"backgroundTag":"invalid-argument-validation","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}