Repository navigation
fix(core): treat VERSION_NEUTRAL in middleware routes as no version - #17947
Merged
kamilmysliwiec merged 3 commits intoSep 30, 2026
Merged
Conversation
With URI versioning, `forRoutes()` or `exclude()` with a route whose `version` is `VERSION_NEUTRAL`, alone or in an array, built the path from the symbol's string, `/vSymbol(VERSION_NEUTRAL)/cats`. Express and Fastify then failed at startup, because path-to-regexp rejects the parenthesis. Give `VERSION_NEUTRAL` an empty version path, as controller routes already do, and skip the exact-match entry of a wildcard route when that leaves no base path to match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
With URI versioning, a middleware route whose
versionisVERSION_NEUTRAL, alone or in an array (both allowed byRouteInfo.version: VersionValue):RouteInfoPathExtractor.extractVersionPathFrom()callstoString()on the symbol and builds/vSymbol(VERSION_NEUTRAL)/cats. Express and Fastify then fail atapp.init():exclude()takes the same path. For controllers,RoutesMapperalready mapsVERSION_NEUTRALto "no version", andRoutePathFactorydoes not add a version segment for it.The new specs against the current
route-info-path-extractor.ts:Issue Number: N/A
What is the new behavior?
extractVersionPathFrom()givesVERSION_NEUTRALan empty version path, so the route above is/cats, and['1', VERSION_NEUTRAL]gives/v1/catsand/cats. For a wildcard route, the exact-match$entry is skipped when the global prefix and the version path are both empty, as the unversioned branch already does; a bare$would otherwise match every route on Fastify.A throwaway app with a
VERSION_NEUTRALcontroller and the middleware above now starts on both adapters, andGET /catsruns the middleware once.Does this PR introduce a breaking change?
Other information
npx vitest run packages/core: 1396 passed.