GoogleContainerTools/skaffold · error

reading user input: %w

Error message

reading user input: %w

What it means

prompt.PortForwardResource asks the user which resources to port-forward using an interactive survey prompt via the `ask` helper. When `ask` returns an error (the terminal cannot run an interactive survey — e.g. not a TTY, interrupted session, or the survey library fails to read stdin), the error is wrapped with "reading user input: %w". It means the initializer could not get the answer it needs to generate skaffold.yaml.

Source

Thrown at pkg/skaffold/initializer/prompt/prompt.go:111

	return chosen, err
}

// PortForwardResource prompts the user to give a port to forward the current resource on
func portForwardResource(out io.Writer, imageName string) (int, error) {
	var response string
	prompt := &survey.Question{
		Prompt: &survey.Input{Message: fmt.Sprintf("Select port to forward for %s (leave blank for none):", imageName)},
		Validate: func(val interface{}) error {
			str := val.(string)
			if _, err := strconv.Atoi(str); err != nil && str != "" {
				return errors.New("response must be a number, or empty")
			}
			return nil
		},
	}
	err := ask([]*survey.Question{prompt}, &response)
	if err != nil {
		return 0, fmt.Errorf("reading user input: %w", err)
	}

	response = strings.ToLower(strings.TrimSpace(response))
	if response == "" {
		return 0, nil
	}

	responseInt, _ := strconv.Atoi(response)
	return responseInt, nil
}

// ConfirmInitOptions prompts the user to confirm that they are okay with what skaffold will do if they
// run with the current config
func ConfirmInitOptions(out io.Writer, config *latest.SkaffoldConfig) (bool, error) {
	builders := strings.Join(util.ListBuilders(&config.Build), ",")
	deployers := strings.Join(util.ListDeployers(&config.Deploy), ",")

	fmt.Fprintf(out, `If you choose to continue, skaffold will do the following:

View on GitHub (pinned to a1189de023)

Solutions

  1. Run skaffold init in an interactive terminal (attach a TTY: `docker run -it ...`).
  2. Use non-interactive flags (e.g. `skaffold init --force` / supply manifest flags) so no prompt is needed.
  3. Pipe valid answers or set --port-forward=false as applicable to skip the prompt.

Example fix

// before
skaffold init < input.txt
// after
skaffold init  # run interactively, or:
skaffold init --force --port-forward=false
Defensive patterns

Strategy: fallback

Validate before calling

if !term.IsTerminal(int(os.Stdin.Fd())) {
    return errors.New("skaffold init requires an interactive terminal or non-interactive flags")
}

Try / catch

if err := runInit(); err != nil {
    if strings.Contains(err.Error(), "reading user input") {
        // fall back to non-interactive init flags
    }
}

Prevention

When it happens

Trigger: Running `skaffold init` with port-forward prompts when stdin/stdout is not an interactive terminal (CI, piped input), the user aborts the prompt (Ctrl+C), or the survey library fails to initialize.

Common situations: Running skaffold init inside Docker/CI where no TTY is attached; running through scripts that redirect stdin; terminal emulators that break survey's ANSI handling.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/046aab1775436b02. Report an issue: GitHub.