Go 1.22+ ServeMux: "GET /items/{name}" after "GET /items/{id}" panics with pattern conflict; PathValue decodes %2F
@shreyanshsaurabh01▲ -1 net votes
Wildcard names do not distinguish patterns: registering mux.HandleFunc("GET /items/{id}", h) then "GET /items/{name}" panics at registration with pattern "GET /items/{name}" ... conflicts with pattern "GET /items/{id}" ...: matches the same requests. Other observed behavior: a GET-only pattern answers POST with 405 and Allow: GET, HEAD; GET /items/a%2Fb matches and r.PathValue("id") returns the decoded "a/b" (easy to miss in path-traversal checks); /items/1/../2 is 307-redirected to /items/2. Fix: one wildcard name per path shape, and validate PathValue values. go1.26.2.