vitessio/vitess · warning

invalid int value for %v: %v

Error message

invalid int value for %v: %v

What it means

The tabletserver debug env endpoint (/debug/env, ADMIN-only) allows live-tuning variables via POST. For integer variables set through setIntVal (MaxResultSize, WarnResultSize), the submitted value must parse with strconv.Atoi; this error is returned — surfaced as HTTP 400 — when the value is not a valid integer.

Source

Thrown at go/vt/vttablet/tabletserver/debugenv.go:97

	default:
		http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
	}
}

func handlePost(tsv *TabletServer, w http.ResponseWriter, r *http.Request) {
	varname := r.FormValue("varname")
	value := r.FormValue("value")

	var msg string
	if varname == "" || value == "" {
		http.Error(w, "Missing varname or value", http.StatusBadRequest)
		return
	}

	setIntVal := func(f func(int)) error {
		ival, err := strconv.Atoi(value)
		if err != nil {
			return fmt.Errorf("invalid int value for %v: %v", varname, err)
		}
		f(ival)
		msg = fmt.Sprintf("Setting %v to: %v", varname, value)
		return nil
	}

	setIntValCtx := func(f func(context.Context, int) error) error {
		ival, err := strconv.Atoi(value)
		if err == nil {
			err = f(r.Context(), ival)
		}
		if err != nil {
			return fmt.Errorf("failed setting value for %v: %v", varname, err)
		}
		msg = fmt.Sprintf("Setting %v to: %v", varname, value)
		return nil
	}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Resubmit the value as a plain base-10 integer, e.g. 10000 instead of 10k
  2. Remove any whitespace, commas, or units from the value
  3. Check the wrapped strconv error in the message for the exact parse problem (syntax vs out-of-range)
  4. Use the /debug/env page's form directly so the varname/value form fields are populated correctly

Example fix

// before: POST value
value="10k"
// after
value="10000"
Defensive patterns

Strategy: validation

Validate before calling

value := "10000"
if _, err := strconv.Atoi(value); err != nil {
    return fmt.Errorf("%s is not a plain base-10 integer", value)
}
// then POST /debug/env?varname=MaxResultSize&value=10000

Try / catch

resp, err := http.PostForm(url, url.Values{"varname": {"MaxResultSize"}, "value": {"10000"}})
if resp.StatusCode == http.StatusBadRequest {
    body, _ := io.ReadAll(resp.Body)
    log.Warn("debug env rejected value", slog.String("body", string(body)))
}

Prevention

When it happens

Trigger: POST /debug/env with varname=MaxResultSize or WarnResultSize and a value that fails strconv.Atoi — e.g. '10k', '1,000', ' 100' (leading space), an empty/whitespace string, or an out-of-int-range number.

Common situations: Operators pasting values with units ('10000k') or thousands separators into the debug env HTML form; curl scripts sending unquoted or locale-formatted numbers.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/ba6a7fe158f747e2. Report an issue: GitHub.