{"record":{"id":"ba6a7fe158f747e2","repo":"vitessio/vitess","slug":"invalid-int-value-for-v-v","errorCode":null,"errorMessage":"invalid int value for %v: %v","messagePattern":"invalid int value for (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"go/vt/vttablet/tabletserver/debugenv.go","lineNumber":97,"sourceCode":"\tdefault:\n\t\thttp.Error(w, \"Method not allowed\", http.StatusMethodNotAllowed)\n\t}\n}\n\nfunc handlePost(tsv *TabletServer, w http.ResponseWriter, r *http.Request) {\n\tvarname := r.FormValue(\"varname\")\n\tvalue := r.FormValue(\"value\")\n\n\tvar msg string\n\tif varname == \"\" || value == \"\" {\n\t\thttp.Error(w, \"Missing varname or value\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tsetIntVal := func(f func(int)) error {\n\t\tival, err := strconv.Atoi(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid int value for %v: %v\", varname, err)\n\t\t}\n\t\tf(ival)\n\t\tmsg = fmt.Sprintf(\"Setting %v to: %v\", varname, value)\n\t\treturn nil\n\t}\n\n\tsetIntValCtx := func(f func(context.Context, int) error) error {\n\t\tival, err := strconv.Atoi(value)\n\t\tif err == nil {\n\t\t\terr = f(r.Context(), ival)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed setting value for %v: %v\", varname, err)\n\t\t}\n\t\tmsg = fmt.Sprintf(\"Setting %v to: %v\", varname, value)\n\t\treturn nil\n\t}\n","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletserver/debugenv.go#L79-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"Operators pasting values with units ('10000k') or thousands separators into the debug env HTML form; curl scripts sending unquoted or locale-formatted numbers.","solutions":["Resubmit the value as a plain base-10 integer, e.g. 10000 instead of 10k","Remove any whitespace, commas, or units from the value","Check the wrapped strconv error in the message for the exact parse problem (syntax vs out-of-range)","Use the /debug/env page's form directly so the varname/value form fields are populated correctly"],"exampleFix":"// before: POST value\nvalue=\"10k\"\n// after\nvalue=\"10000\"","handlingStrategy":"validation","validationCode":"value := \"10000\"\nif _, err := strconv.Atoi(value); err != nil {\n    return fmt.Errorf(\"%s is not a plain base-10 integer\", value)\n}\n// then POST /debug/env?varname=MaxResultSize&value=10000","typeGuard":null,"tryCatchPattern":"resp, err := http.PostForm(url, url.Values{\"varname\": {\"MaxResultSize\"}, \"value\": {\"10000\"}})\nif resp.StatusCode == http.StatusBadRequest {\n    body, _ := io.ReadAll(resp.Body)\n    log.Warn(\"debug env rejected value\", slog.String(\"body\", string(body)))\n}","preventionTips":["Always submit plain base-10 integers — no units (10k), commas, spaces, or signs other than leading '-'","Verify values with strconv.Atoi locally before scripting the POST","Use the /debug/env HTML form so varname/value fields are populated correctly","Remember int overflow also fails — keep values within Go int range"],"tags":["tabletserver","http","validation","go"],"backgroundTag":"invalid-integer-input","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}