router: a request can go to the broader rule when two rule paths overlap
Author: omlahoreCreated Sep 26, 2026Updated Sep 26, 2026
I registered /nsN/a and /nsN/a/b as listeners for 100 namespaces and sent /node1/nsN/a/b through RestHandler.matchedPath on master, and 44 of the 100 came back as /nsN/a instead of /nsN/a/b. matchedPath only swaps in a new match when RuleContains(new, current) is false (http.go#L95-L100). RuleContains stops comparing at the shorter path (path.go#L49-L55), so it says /a/b contains /a as well as the other way round. Whichever rule sync.Map.Range reaches first wins, and that order is different for each key.
I think returning false when rule2Path has fewer segments than rulePath would be enough for matchedPath to keep the more specific rule.
Source: kubeedge/kubeedge