GoogleContainerTools/skaffold · warning
response must be a number, or empty
Error message
response must be a number, or empty
What it means
During skaffold initializer prompting, the user is asked to select a port to forward for each discovered image. The survey validator attempts strconv.Atoi on the response and, if it is neither a number nor an empty string, returns 'response must be a number, or empty'. This is interactive input validation, not an internal failure.
Source
Thrown at pkg/skaffold/initializer/prompt/prompt.go:104
Options: builders,
}
err := askOne(prompt, &chosen)
if err != nil {
return []string{}, fmt.Errorf("getting user choices")
}
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
}
View on GitHub (pinned to a1189de023)
Solutions
- Enter just the numeric port (e.g. 8080) or press Enter to skip forwarding for that image
- If pasting from docker ps, extract only the container port number from the mapping
- Rerun skaffold init and answer prompts carefully; use the --portforward flag or edit skaffold.yaml afterward to set port forwards non-interactively
Example fix
// before (prompt input) Select port to forward for my-image: 0.0.0.0:8080->80/tcp // after Select port to forward for my-image: 8080 # or leave blank to skip
Defensive patterns
Strategy: validation
Validate before calling
func validPortAnswer(s string) bool {
if s == "" { return true }
_, err := strconv.Atoi(strings.TrimSpace(s))
return err == nil
} Type guard
func isPortNumber(val interface{}) bool {
s, ok := val.(string)
if !ok { return false }
if s == "" { return true }
n, err := strconv.Atoi(s)
return err == nil && n > 0 && n < 65536
} Try / catch
if err := ask(questions, &response); err != nil {
if strings.Contains(err.Error(), "response must be a number, or empty") {
fmt.Println("Enter a plain number (e.g. 8080) or press Enter to skip.")
err = ask(questions, &response) // re-prompt
}
} Prevention
- Enter only digits at port prompts; no mappings or protocol suffixes
- Use non-interactive flags (--default-repo, --portforward) or edit skaffold.yaml to avoid prompts in CI
- Trim pasted docker ps output to just the container port
When it happens
Trigger: Typing non-numeric input (e.g. '8080/tcp', 'eighty', '8o80') at the 'Select port to forward for <image>' prompt instead of a number or blank line.
Common situations: Copy-pasting a port mapping like '0.0.0.0:8080->80/tcp' from docker ps output; typos; pasting with trailing whitespace/characters; expecting to enter a protocol suffix.
Related errors
- cannot add an empty image value
- strings.Join(messages, "\n")
- strings.Join(messages, " \n ")
- tagging policy 'sha256' can not be used when 'tryImportMissi
- INIT_DOCKER_NETWORK_INVALID_MODE
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/d0e04f1870b121fa.
Report an issue: GitHub.