Skip to content

fix(common): invoke proto-key stripping hook via this in transform - #17761

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
koreahghg:fix/validation-pipe-strip-proto-keys-override
Sep 15, 2026
Merged

kamilmysliwiec merged 1 commit into
nestjs:masterfrom
koreahghg:fix/validation-pipe-strip-proto-keys-override

Conversation

@koreahghg

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

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?

ValidationPipe and StandardSchemaValidationPipe both expose a protected stripProtoKeys(value) method that is clearly intended as an overridable extension point (existing "subclass compatibility" specs already call super.stripProtoKeys(...) from a subclass). However, transform() in both classes calls the standalone stripProtoKeys(value) helper function directly instead of this.stripProtoKeys(value).

As a result, if a consumer subclasses either pipe and overrides stripProtoKeys() (e.g. to customize prototype-pollution key stripping for their app), the override is silently never invoked at runtime — transform() always runs the base behavior instead.

Issue Number: N/A

What is the new behavior?

Both transform() methods now call this.stripProtoKeys(value), so a subclass override is correctly invoked during validation. Added a regression test to each pipe's spec file asserting that an overridden stripProtoKeys is actually called during transform().

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Verified: full packages/common test suite (751 tests) passes, and oxlint is clean on the changed files.

ValidationPipe and StandardSchemaValidationPipe both expose a
protected method meant to be overridden by subclasses to customize
proto-key stripping, but transform() called the standalone helper
function directly instead of going through the instance method, so a
subclass override was silently never invoked.
@kamilmysliwiec
kamilmysliwiec merged commit d00202a into nestjs:master Sep 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants