{"record":{"id":"4f8d8d920282ded8","repo":"go-task/task","slug":"prompt-cancelled","errorCode":null,"errorMessage":"prompt cancelled","messagePattern":"prompt cancelled","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/input/input.go","lineNumber":15,"sourceCode":"package input\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n\n\t\"charm.land/bubbles/v2/textinput\"\n\ttea \"charm.land/bubbletea/v2\"\n\t\"charm.land/lipgloss/v2\"\n\n\t\"github.com/go-task/task/v3/errors\"\n)\n\nvar ErrCancelled = errors.New(\"prompt cancelled\")\n\nvar (\n\tpromptStyle   = lipgloss.NewStyle().Foreground(lipgloss.Color(\"6\")).Bold(true) // cyan bold\n\tcursorStyle   = lipgloss.NewStyle().Foreground(lipgloss.Color(\"6\")).Bold(true) // cyan bold\n\tselectedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(\"2\")).Bold(true) // green bold\n\tdimStyle      = lipgloss.NewStyle().Foreground(lipgloss.Color(\"8\"))            // gray\n)\n\n// Prompter handles interactive variable prompting\ntype Prompter struct {\n\tStdin  io.Reader\n\tStdout io.Writer\n\tStderr io.Writer\n}\n\n// Text prompts the user for a text value\nfunc (p *Prompter) Text(varName string) (string, error) {\n\tm := newTextModel(varName)","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/go-task/task/blob/385e5ad92af02877b6d7cf9dcc963b5ed916e70a/internal/input/input.go#L1-L33","documentation":"internal/input returns the sentinel ErrCancelled when the user aborts a Bubble Tea prompt (Text or Select) by pressing ctrl+c/esc. It signals that prompt input did not complete, not an internal failure.","triggerScenarios":"Calling Prompter.Text or Prompter.Select and the user cancels; promptDepsVars or promptTaskVars propagate it when variable prompting is aborted.","commonSituations":"Users hit ctrl+c or esc at an interactive variable prompt during a `task --prompt` / vars-driven run; CI wrappers that expect a value get cancellation instead.","solutions":["Re-run the task and complete or answer the prompt","Use errors.Is(err, input.ErrCancelled) to detect cancellation and exit or substitute defaults","Run non-interactively (supply the variables up front) to avoid prompts entirely"],"exampleFix":"// before\nv, _ := p.Text(\"name\")\n// after\nv, err := p.Text(\"name\")\nif errors.Is(err, input.ErrCancelled) {\n    return fmt.Errorf(\"prompt cancelled by user\")\n}","handlingStrategy":"try-catch","validationCode":"// Nothing to pre-validate: cancellation is a runtime user action.\nif !isInteractive(os.Stdin) {\n    // supply vars up front to avoid prompting\n}","typeGuard":"func isPromptCancelled(err error) bool {\n    return errors.Is(err, input.ErrCancelled)\n}","tryCatchPattern":"v, err := p.Text(\"name\")\nif errors.Is(err, input.ErrCancelled) {\n    // user aborted: exit cleanly or use default\n    v = defaultValue\n} else if err != nil {\n    return err\n}","preventionTips":["Provide variables on the command line to skip prompts in scripts","Check errors.Is(err, input.ErrCancelled) rather than comparing error text","In CI, detect non-TTY stdin and pass all prompted vars explicitly"],"tags":["interactive","prompt","user-cancel"],"backgroundTag":"prompt-cancelled","analyzedSha":"385e5ad92af02877b6d7cf9dcc963b5ed916e70a","analyzedAt":"2026-09-05T09:01:05.226Z","contentChangedAt":"2026-09-05T09:01:05.226Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}