{"record":{"id":"fcac482cf0e9342f","repo":"plandex-ai/plandex","slug":"failed-to-read-piped-data-v","errorCode":null,"errorMessage":"failed to read piped data: %v","messagePattern":"failed to read piped data: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/context_load.go","lineNumber":75,"sourceCode":"\t}\n\n\tif params.Note != \"\" {\n\t\tloadContextReq = append(loadContextReq, &shared.LoadContextParams{\n\t\t\tContextType: shared.ContextNoteType,\n\t\t\tBody:        params.Note,\n\t\t\tApiKeys:     authVars,\n\t\t\tOpenAIBase:  openAIBase,\n\t\t\tOpenAIOrgId: os.Getenv(\"OPENAI_ORG_ID\"),\n\t\t\tSessionId:   params.SessionId,\n\t\t\tAutoLoaded:  params.AutoLoaded,\n\t\t})\n\t}\n\n\tif fileInfo.Mode()&os.ModeNamedPipe != 0 {\n\t\treader := bufio.NewReader(os.Stdin)\n\t\tpipedData, err := io.ReadAll(reader)\n\t\tif err != nil {\n\t\t\tonErr(fmt.Errorf(\"failed to read piped data: %v\", err))\n\t\t}\n\n\t\tif len(pipedData) > 0 {\n\t\t\tloadContextReq = append(loadContextReq, &shared.LoadContextParams{\n\t\t\t\tContextType: shared.ContextPipedDataType,\n\t\t\t\tBody:        string(pipedData),\n\t\t\t\tApiKeys:     authVars,\n\t\t\t\tOpenAIBase:  openAIBase,\n\t\t\t\tOpenAIOrgId: os.Getenv(\"OPENAI_ORG_ID\"),\n\t\t\t\tSessionId:   params.SessionId,\n\t\t\t\tAutoLoaded:  params.AutoLoaded,\n\t\t\t})\n\t\t}\n\t}\n\n\tvar inputUrls []string\n\tvar inputFilePaths []string\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/context_load.go#L57-L93","documentation":"In MustLoadContext, when stdin is a named pipe, io.ReadAll on a bufio.Reader over os.Stdin fails while consuming piped input. The pipe writer closed with an error or the read was interrupted, so the piped content cannot be loaded as context.","triggerScenarios":"io.ReadAll(reader) returns an error while reading piped stdin — writer closed abruptly, pipe broken (reader process killed), or I/O error on the stdin fd.","commonSituations":"`some_cmd | plandex load ...` where the producing command crashed or was killed mid-stream; reading from a pipe over an interrupted ssh/session; extremely large pipe payloads hit an fd/stream error.","solutions":["Re-run the upstream command and confirm it exits successfully before piping","Check for broken pipe messages and disk/fd limits (ulimit)","Test with a small known payload: `echo hi | plandex ...`","If data comes over ssh/network, verify connection stability"],"exampleFix":"// before\npipedData, err := io.ReadAll(reader)\nif err != nil {\n\tonErr(fmt.Errorf(\"failed to read piped data: %v\", err))\n}\n// after\npipedData, err := io.ReadAll(reader)\nif err != nil {\n\tonErr(fmt.Errorf(\"failed to read piped data after %d bytes: %w\", len(pipedData), err))\n}","handlingStrategy":"try-catch","validationCode":"// verify the upstream producer exits 0 before piping\nsome_cmd > /tmp/out.txt && plandex load /tmp/out.txt || echo \"producer failed\"","typeGuard":"// Go: ensure reader is non-nil and stdin is a live pipe\nfunc pipeReadable() bool {\n\tfi, err := os.Stdin.Stat()\n\treturn err == nil && fi.Mode()&os.ModeNamedPipe != 0 && fi.Size() != 0\n}","tryCatchPattern":"// Go: read with error context including bytes captured\npipedData, err := io.ReadAll(reader)\nif err != nil {\n\treturn fmt.Errorf(\"failed to read piped data after %d bytes: %w\", len(pipedData), err)\n}","preventionTips":["Confirm the piped command succeeds before piping (`cmd && cmd2 | plandex`)","Avoid piping huge streams over unstable ssh sessions","Write intermediate output to a file for very large payloads","Keep ulimit/fd settings from breaking long reads"],"tags":["stdin","pipe","io","cli"],"backgroundTag":"broken-pipe-read-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}