fix(ldap): remove DTO default initializers that clobbered partial updates
CreateLdapConfigDto's optional fields (searchFilter, syncIntervalMin, isActive, groupFilterDns) had class-field default initializers. NestJS's ValidationPipe instantiates DTOs via plainToInstance, which applies those defaults even when the field is absent from the request body -- so any partial PATCH not including a given field silently reset it to the hardcoded default instead of leaving it untouched. Caught by testing the new groupFilterDns-only PATCH: saving the group filter alone reset searchFilter back to "(objectClass=person)", clobbering the configured Active Directory filter. The service layer already has its own `?? default` fallback for create, so the DTO initializers were redundant and unsafe. Removing them makes updateConfig's existing "only set if dto.field !== undefined" pattern behave correctly for every optional field, not just the ones sent together in one request. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,21 +31,21 @@ export class CreateLdapConfigDto {
|
|||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
searchFilter?: string = '(objectClass=person)';
|
searchFilter?: string;
|
||||||
|
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@Min(0)
|
@Min(0)
|
||||||
syncIntervalMin?: number = 60;
|
syncIntervalMin?: number;
|
||||||
|
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
isActive?: boolean = true;
|
isActive?: boolean;
|
||||||
|
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@IsString({ each: true })
|
@IsString({ each: true })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
groupFilterDns?: string[] = [];
|
groupFilterDns?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user