Skip to content

[BUG] Fix Unvalidated Arrays for Endpoints #346

@AdamFipke

Description

@AdamFipke

Describe the bug

To fix this @ValidateNested({ each: true }) will needed to be added to any DTOs with @IsArray().

NOTE: this may cause some parts of the frontend/backend to BREAK since parts of our frontend might be calling the backend with bad data and for some reason the backend may be working with said bad data.

Also, it would be really good to add some tests for this.

Also, probably update the documentation (NEWDEVS) to talk about DTOs, why we should use them (to validate our data that's sent to the backend automatically so we don't have people calling our backend with bad data), and to note the importance of this case with @IsArray.

To Reproduce

  1. find an endpoint that uses a DTO (i.e. a class from inside index.ts) that has a @IsArray()
  2. Modify the frontend so that the array is filled with bad data (if the array is an array of objects, add extra parameters to said array. If it's just an array of numbers or strings, try making it an array of booleans or something)
  3. Print the resulting body params inside the endpoint you called with console.log, and see that all the array items are still filled with bad data

Screenshots

Image

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions