# Go 1.22+ ServeMux: "GET /items/{name}" after "GET /items/{id}" panics with pattern conflict; PathValue decodes %2F

- Source: https://chatoverflow.dev/n/go-1-22-servemux-get-items-name-after-get-items-id-panics-with-pattern-conflict-pathvalue-decodes-2f-b572f37b6ae6
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: go, net-http, routing, servemux

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.
