{"record":{"id":"afccf119ff9cd8de","repo":"stablyai/orca","slug":"could-not-read-helper-socket-path-from-command","errorCode":null,"errorMessage":"Could not read helper socket path from command: ${command}","messagePattern":"Could not read helper socket path from command: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/macos-computer-helper-owner-loss-benchmark.mjs","lineNumber":184,"sourceCode":"      if (\n        match &&\n        Number(match[2]) === sidecarPid &&\n        Number(match[3]) === Number(match[1]) &&\n        match[4].includes(helperPath) &&\n        match[4].includes(' --agent ')\n      ) {\n        return { pid: Number(match[1]), pgid: Number(match[3]), command: match[4] }\n      }\n    }\n    await sleep(50)\n  }\n  throw new Error(`Could not find helper owned by sidecar ${sidecarPid}`)\n}\n\nfunction socketPathFromCommand(command) {\n  const match = command.match(/ --agent (.+?) --token-file /)\n  if (!match) {\n    throw new Error(`Could not read helper socket path from command: ${command}`)\n  }\n  return match[1]\n}\n\nfunction connectInvalidPeer(socketPath) {\n  return new Promise((resolve, reject) => {\n    const socket = net.createConnection(socketPath)\n    let accepted = false\n    const timeout = setTimeout(() => {\n      socket.destroy()\n      reject(new Error('Invalid-peer connection timed out'))\n    }, 5_000)\n    let buffer = ''\n    const cleanup = () => {\n      clearTimeout(timeout)\n      socket.off('error', onError)\n      socket.off('data', onData)\n    }","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/macos-computer-helper-owner-loss-benchmark.mjs#L166-L202","documentation":"socketPathFromCommand extracts the helper's unix socket path from its command line using the regex / --agent (.+?) --token-file /. It throws when the regex does not match, meaning the helper was not launched with the expected --agent <socket> --token-file <file> argument shape, so the socket path cannot be derived for an invalid-peer connection test.","triggerScenarios":"The helper command line changed argument order or names (e.g. --socket instead of --agent), the --token-file flag is absent, or socketPathFromCommand was handed a truncated/wrong command string.","commonSituations":"A helper version that renamed its flags, a launch wrapper that reorders argv, or capturing only part of the command line from ps so the two-flag pattern is split across the cut.","solutions":["Log the command string passed in and confirm both --agent and --token-file are present and in that order.","If the helper renamed the flag, update the regex to the new argument shape.","When reading the command from ps, request the full command line (ps -o command= or ww) so it is not truncated."],"exampleFix":"// before\nconst match = command.match(/ --agent (.+?) --token-file /)\nif (!match) throw new Error(`Could not read helper socket path from command: ${command}`)\n\n// after\nconst match = command.match(/ --agent (.+?) --token-file /)\nif (!match) {\n  throw new Error(`Could not read helper socket path from command: ${command.slice(0, 300)}`)\n}","handlingStrategy":"validation","validationCode":"function parseSocketPath(command) {\n  const m = command.match(/ --agent (.+?) --token-file /)\n  if (!m) throw new Error(`helper command missing --agent/--token-file: ${command.slice(0,300)}`)\n  return m[1]\n}","typeGuard":"const hasSocketFlags = (cmd) => / --agent .+? --token-file /.test(cmd)","tryCatchPattern":null,"preventionTips":["Read the full command line (ps ww / -o command=) so flags aren't truncated.","If the helper renamed flags, update the regex in lockstep.","Unit-test the regex against a sample real helper command line."],"tags":["regex","helper","command-line","macos"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}