{"record":{"id":"7315d9c42f5c9950","repo":"antonmedv/fx","slug":"error-returned-from-pipeline-p-run-panic-err","errorCode":null,"errorMessage":"<error returned from pipeline p.Run()> (panic(err))","messagePattern":"<error returned from pipeline p\\.Run\\(\\)> \\(panic\\(err\\)\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":326,"sourceCode":"\t\t\t\t\tp.Send(errorMsg{err: err})\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\ttextNode := parser.Recover()\n\t\t\t\tif !firstOk && !strings.HasPrefix(textNode.Value, \"HTTP\") {\n\t\t\t\t\tp.Send(errorMsg{err: err})\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tp.Send(nodeMsg{node: textNode})\n\t\t\t} else {\n\t\t\t\tfirstOk = true\n\t\t\t\tp.Send(nodeMsg{node: node})\n\t\t\t}\n\t\t}\n\t}()\n\n\t_, err := p.Run()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif m.printErrorOnExit != nil {\n\t\tfmt.Println(m.printErrorOnExit.Error())\n\t} else if m.printOnExit {\n\t\tfmt.Println(m.cursorValue())\n\t} else {\n\t\texit()\n\t}\n}\n\ntype model struct {\n\ttermWidth, termHeight int\n\thead, top, bottom     *Node\n\teof                   bool\n\tcursor                int // cursor position [0, termHeight)\n\tsuspending            bool\n\tshowCursor            bool","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/antonmedv/fx/blob/4f31cd3a0c5d66f1b4290a2719bab14a5cee8ebe/main.go#L308-L344","documentation":"main runs the interactive pipeline via p.Run() and panics if the pipeline returns an error. All normal errors (parse errors, expression errors) are expected to be carried elsewhere (e.g. m.printErrorOnExit); an error reaching this point indicates an unexpected pipeline failure such as a terminal setup fault or an internal state violation.","triggerScenarios":"p.Run() returns a non-nil error — typically a bubbletea/termenv-style terminal failure: failure to open /dev/tty, unsupported TERM, or an unrecovered renderer panic surfaced as an error.","commonSituations":"Running fx in an environment without a TTY (CI, non-interactive SSH, docker run without -t); TERM set to 'dumb' or unset; terminal too small or terminfo missing.","solutions":["Run fx in an interactive terminal (allocate a TTY: docker run -t, ssh -t)","Set TERM to a supported value (e.g. xterm-256color) or unset TERM=dumb","Use non-interactive mode (pipe output, no TTY usage) when a TTY is unavailable","Check the wrapped error message for the specific terminal subsystem failure and update the terminal library if it's a known bug"],"exampleFix":"// before\n_, err := p.Run()\nif err != nil {\n\tpanic(err)\n}\n// after\n_, err := p.Run()\nif err != nil {\n\tfmt.Fprintf(os.Stderr, \"interactive mode failed: %v\\n\", err)\n\tos.Exit(1)\n}","handlingStrategy":"fallback","validationCode":"// detect TTY availability before running interactive mode\nif term.IsTerminal(int(os.Stdin.Fd())) == false && mode == interactive {\n\t// fall back to non-interactive processing\n}","typeGuard":null,"tryCatchPattern":"// recover around pipeline execution\n_, err := func() (out any, err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"pipeline panicked: %v\", r)\n\t\t}\n\t}()\n\treturn p.Run()\n}()","preventionTips":["Always run fx in an environment with an allocated TTY (docker run -t, ssh -t)","Avoid TERM=dumb or unset TERM in interactive sessions","Provide a non-interactive fallback path (batch mode) for CI environments","Keep the TUI library up to date for terminal-backend fixes"],"tags":["go","panic","terminal","tty","pipeline"],"backgroundTag":"tty-not-available","analyzedSha":"4f31cd3a0c5d66f1b4290a2719bab14a5cee8ebe","analyzedAt":"2026-09-02T02:17:47.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}