From b736cddf07f89a7bca6d04e3477b655b38576414 Mon Sep 17 00:00:00 2001 From: Rafael Date: Mon, 12 Jan 2026 16:22:25 -0300 Subject: [PATCH] FIX: Update ValidationPipe for class-validator 0.14.0+ compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix addresses a breaking change introduced in class-validator 0.14.0 where the default for forbidUnknownValues changed from false to true. Issue: - POST /connections was returning 400 "an unknown value was passed to the validate function" errors - This occurred because CreateConnectionDto and UpdateConnectionDto have no validation decorators, causing class-validator 0.14.0+ to treat them as "unknown values" - Extra fields (like connector_version) in request payloads would fail validation Solution: - Set forbidUnknownValues: false to allow DTOs without validation decorators - Set whitelist: true to automatically strip extra properties not defined in DTOs - This maintains backward compatibility while adding security by removing unexpected fields 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/pipes/object-validation.pipe.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pipes/object-validation.pipe.ts b/src/pipes/object-validation.pipe.ts index 1014581..1315083 100644 --- a/src/pipes/object-validation.pipe.ts +++ b/src/pipes/object-validation.pipe.ts @@ -14,7 +14,10 @@ export class ValidationPipe implements PipeTransform { return value; } const object = plainToInstance(metatype, value); - const errors = await validate(object); + const errors = await validate(object, { + forbidUnknownValues: false, + whitelist: true, + }); if (errors.length > 0) { const errorMessages = errors.map((err) => err.constraints); throw new BadRequestException(errorMessages);