{"record":{"id":"27c5c7e428c20be8","repo":"charmbracelet/gum","slug":"failed-to-run-input-w","errorCode":null,"errorMessage":"failed to run input: %w","messagePattern":"failed to run input: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"input/command.go","lineNumber":72,"sourceCode":"\t\theaderStyle: o.HeaderStyle.ToLipgloss(),\n\t\tpadding:     []int{top, right, bottom, left},\n\t\tautoWidth:   o.Width < 1,\n\t\tshowHelp:    o.ShowHelp,\n\t\thelp:        help.New(),\n\t\tkeymap:      defaultKeymap(),\n\t}\n\n\tctx, cancel := timeout.Context(o.Timeout)\n\tdefer cancel()\n\n\tp := tea.NewProgram(\n\t\tm,\n\t\ttea.WithOutput(os.Stderr),\n\t\ttea.WithContext(ctx),\n\t)\n\ttm, err := p.Run()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to run input: %w\", err)\n\t}\n\n\tm = tm.(model)\n\tif !m.submitted {\n\t\treturn errors.New(\"not submitted\")\n\t}\n\tfmt.Println(m.textinput.Value())\n\treturn nil\n}\n","sourceCodeStart":54,"sourceCodeEnd":82,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/input/command.go#L54-L82","documentation":"gum input runs a Bubble Tea program (with output on stderr and the caller's context). If `p.Run()` itself fails — the context is cancelled/deadline exceeded, the terminal cannot be initialized, or writing output fails — Run wraps it as `failed to run input: %w`. Unlike \"not submitted\", the prompt never ran to completion at all.","triggerScenarios":"The context passed via `tea.WithContext(ctx)` is cancelled or exceeds its deadline while the prompt is open; stdin/stdout/stderr are not a usable TTY; terminal setup (raw mode, size query) fails.","commonSituations":"Timeouts wrapping gum invocations (e.g. `timeout 5 gum input ...`) killing the prompt; non-interactive CI environments lacking a pty; embedded Go callers cancelling the context programmatically.","solutions":["Inspect the wrapped cause: if it is `context.DeadlineExceeded`, increase the timeout or remove the deadline.","Run in a real terminal or allocate a pty when invoked from scripts/CI.","Pass a context that lives as long as the user interaction should, not one tied to a short request.","Check TERM and terminal capabilities; force a known TERM value in constrained environments."],"exampleFix":"// before\nctx, cancel := context.WithTimeout(ctx, 2*time.Second)\ndefer cancel()\nm, err := input.Run(...) // fails: failed to run input: context deadline exceeded\n// after\nctx, cancel := context.WithTimeout(ctx, 5*time.Minute) // allow time for user input\ndefer cancel()","handlingStrategy":"validation","validationCode":"[ -t 0 ] && [ -t 1 ] || { echo \"gum input needs a TTY\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! value=$(timeout 300 gum input); then\n  echo \"failed to run input (timeout or TTY issue)\" >&2\nfi","preventionTips":["Verify a usable TTY before starting interactive prompts.","Avoid short `timeout` wrappers around interactive commands.","Check TERM is set to a supported value in the execution environment.","Pass long-lived contexts when embedding gum's Go API."],"tags":["go","cli","context-cancelled","tui"],"backgroundTag":"context-deadline-exceeded","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}