Skip to content

fix: when version is an array with neutral version - #9585

Merged
kamilmysliwiec merged 4 commits into
nestjs:masterfrom
micalevisk:fix-issue-9581
May 17, 2022
Merged

kamilmysliwiec merged 4 commits into
nestjs:masterfrom
micalevisk:fix-issue-9581

Conversation

@micalevisk

@micalevisk micalevisk commented May 17, 2022 •

Copy link
Copy Markdown
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: closes #9581

What is the new behavior?

now having version: [VERSION_NEUTRAL] will behave the same as version: VERSION_NEUTRAL

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

I've tested those changes with both adapters in a local project of mine

@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 2932a840-1413-4100-9224-94da6d81e1d1

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 94.119%

Totals Coverage Status
Change from base Build 80326ff7-d845-42a0-80c8-3aa6fe83ef88: 0.006%
Covered Lines: 5777
Relevant Lines: 6138

💛 - Coveralls

Comment thread packages/core/router/router-explorer.ts Resolved
@kamilmysliwiec
kamilmysliwiec merged commit bad85d9 into nestjs:master May 17, 2022
@micalevisk
micalevisk deleted the fix-issue-9581 branch May 18, 2022 11:30
kamilmysliwiec pushed a commit that referenced this pull request Sep 14, 2026
…7705)

* fix(fastify): derive neutral version when accept header is absent

With MEDIA_TYPE versioning, a request without an Accept header
initialized the version parameter to '' instead of undefined, so the
isUndefined guard added in #9585 (whose comment says 'No version was
supplied') never fired. The derived constraint became undefined and
find-my-way skipped routes registered with [VERSION_NEUTRAL, ...]
arrays, returning 404. The HEADER branch of the same function, the
present-but-versionless Accept sub-case, and the Express adapter all
resolve this case to VERSION_NEUTRAL.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(fastify): address review feedback on version filter specs

Fold the standalone media-type repro spec into fastify-adapter.spec.ts
as an applyVersionFilter describe block, dropping both any casts by
typing the options as VersioningOptions and passing the version array
directly (VersionValue accepts Array<string | typeof VERSION_NEUTRAL>).
Add integration coverage: a route versioned [VERSION_NEUTRAL, '2'] plus
a No Header case in both media-type versioning e2e suites. The express
suite passes on the current adapter; the fastify case exercises the fix.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple version including VERSION_NEUTRAL return 404

5 participants