{"record":{"id":"dd8be27369cd8342","repo":"Yeachan-Heo/oh-my-codex","slug":"malformed-detached-leader-authority","errorCode":null,"errorMessage":"malformed detached leader authority","messagePattern":"malformed detached leader authority","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/index.ts","lineNumber":1516,"sourceCode":"};\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. */\nexport function parseDetachedLeaderPaneIdByPid(snapshot: string, leaderPid: number): string {\n  if (!Number.isSafeInteger(leaderPid) || leaderPid <= 0) throw new Error(\"invalid detached leader pid\");\n  const matches = snapshot\n    .split(\"\\n\")\n    .map((line) => line.trim())\n    .filter(Boolean)","sourceCodeStart":1498,"sourceCodeEnd":1534,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L1498-L1534","documentation":"After querying tmux display-message, the helper expects exactly 7 tab-separated fields. A different count means the tmux output format didn't match expectations (old/new tmux version, format string mismatch, or error text in output).","triggerScenarios":"execTmuxFileSync returns output that splits into != 7 fields — e.g. tmux emitted an error, or the format specifier was altered.","commonSituations":"Tmux version differences changing format expansion; target pane missing causing error output; locale/format regressions.","solutions":["Run the display-message command manually with -t <pane> and inspect the output","Verify the tmux version supports all used format variables","Check that the target pane still exists"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const fields = output.trim().split('\\t');\nif (fields.length !== 7) throw new Error('unexpected tmux output');","typeGuard":null,"tryCatchPattern":"catch (e) { if (e.message === 'malformed detached leader authority') { /* log raw tmux output, re-discover leader */ } }","preventionTips":["Pin a tested tmux version","Log raw display-message output when debugging"],"tags":["tmux","output-parsing","validation","internal-api"],"backgroundTag":"external-command-output-parsing","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}