A path based version cannot be optional as its built into the URL path structure and mappings, and therefore it's expected to be in the path, and cannot be optional.
This should be reflected in the implementation, which currently returns null
if there is no parsed path (but that's unrelated, PathPattern
vs AntPathMatcher
, and should be illegal state).
It can also return null
if there aren't enough path segments, but should be a bad request. It's a bit random to treat insufficient number of path segments leniently, but enough path segments that are not of the right kind as an bad request (parse exception).
Based on discussion in https://github.com/spring-projects/spring-framework/issues/35255#issuecomment-3139732891.