vitessio/vitess · warning
Method not allowed
Error message
Method not allowed
What it means
The tabletserver /debugenv endpoint only accepts POST (set a variable) and GET (read variables); any other HTTP method gets a 405 'Method not allowed'. This is method-based routing in debugEnvHandler's switch on r.Method.
Source
Thrown at go/vt/vttablet/tabletserver/debugenv.go:80
return append(vars, envValue{
Name: name,
Value: fmt.Sprintf("%v", f()),
})
}
func debugEnvHandler(tsv *TabletServer, w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {
acl.SendError(w, err)
return
}
switch r.Method {
case http.MethodPost:
handlePost(tsv, w, r)
case http.MethodGet:
handleGet(tsv, w, r)
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)
}View on GitHub (pinned to 01a25a7d17)
Solutions
- Use POST to set a variable (varname/value form fields) or GET to list them
- Fix the client/proxy to send GET or POST only
- If a middleware rewrites methods, whitelist /debugenv from such rewrites
Example fix
// before curl -X PUT 'http://tablet:15100/debugenv?varname=x&value=1' // after curl -X POST 'http://tablet:15100/debugenv' -d 'varname=x&value=1'
Defensive patterns
Strategy: validation
Validate before calling
if method != http.MethodGet && method != http.MethodPost {
return fmt.Errorf("/debugenv only supports GET and POST, got %s", method)
} Prevention
- Only use GET (read) or POST (set) against /debugenv
- Disable method-rewriting middleware for vttablet debug endpoints
- Configure health checkers to use GET
When it happens
Trigger: Sending PUT, DELETE, HEAD, etc. to /debugenv on a vttablet's debug port.
Common situations: REST clients or proxies assuming full CRUD on debug endpoints; misconfigured health checkers using HEAD/DELETE; copy-pasted client code hitting the wrong verb.
Related errors
- Missing varname or value
- err.Error() (invalid variable set value)
- cannot parse form: %s
- err.Error() (JSON marshal failure)
- invalid connID
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/98f42f583d14ce65.
Report an issue: GitHub.