{"record":{"id":"ac7036265a6c32a7","repo":"paperclipai/paperclip","slug":"setup-token-pty-open-failed","errorCode":"SETUP_TOKEN_PTY_OPEN_FAILED","errorMessage":"SETUP_TOKEN_PTY_OPEN_FAILED","messagePattern":"SETUP_TOKEN_PTY_OPEN_FAILED","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/plugin-worker-manager.ts","lineNumber":1437,"sourceCode":"          environmentId: input.environmentId,\n          providerLeaseId: input.providerLeaseId,\n          command: input.command,\n        },\n        setupTokenPtyOpenTimeoutMs,\n      );\n    } catch (err) {\n      // A send failure, an RPC rejection, or an open timeout. Terminalize the\n      // route exactly once and fail closed.\n      await terminalizeSetupTokenPtyRoute(route);\n      throw err instanceof Error ? err : new Error(SETUP_TOKEN_PTY_OPEN_FAILED);\n    }\n\n    const workerSessionId = readBindableWorkerSessionId(route, openResult);\n    if (!workerSessionId) {\n      // A malformed reply, or a route that already left `opening`. A late or a\n      // duplicate reply never binds, revives, or reopens a route.\n      await terminalizeSetupTokenPtyRoute(route);\n      throw new Error(SETUP_TOKEN_PTY_OPEN_FAILED);\n    }\n    // Bind the worker session identifier one time and move the route to `open`.\n    route.workerSessionId = workerSessionId;\n    route.state = \"open\";\n\n    return {\n      onData(listener: (chunk: string) => void): void {\n        route.listener = listener;\n        if (route.buffered.length > 0) {\n          const pending = route.buffered;\n          route.buffered = [];\n          for (const chunk of pending) listener(chunk);\n        }\n      },\n      write(data: string): void {\n        const sid = route.workerSessionId;\n        if (route.state !== \"open\" || !sid) return;\n        void callInternal(","sourceCodeStart":1419,"sourceCodeEnd":1455,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/server/src/services/plugin-worker-manager.ts#L1419-L1455","documentation":"The worker RPC to open the setup-token PTY failed (send error, rejection, or timeout), or the reply was malformed with no bindable worker session id. The route is terminalized once and this sentinel is raised to fail closed.","triggerScenarios":"Thrown at server/src/services/plugin-worker-manager.ts:1229 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The PTY failed to open. Check server logs for the underlying spawn error (command not found, permissions) and retry."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}