RoyDefined / WebDoomer

WebDoomer is a fast and efficient Zandronum and QZandronum server browser as a web app.
GNU General Public License v3.0
4 stars 0 forks source link

Zod errors when fetching server details #28

Closed RoyDefined closed 1 month ago

RoyDefined commented 6 months ago

Describe the bug A Zod error is thrown when fetching detailed information of particular servers. One error is about a player name being parsed incorrectly so this name should either be accepted as "empty" or the player should not be drawn at all. The other is about PWad names, which has the same issue.

Steps to reproduce N/A

Expected behavior Zod parses the data correctly.

Screenshots N/A

Additional context

ZodError: [
  {
    "code": "too_small",
    "minimum": 1,
    "type": "string",
    "inclusive": true,
    "exact": false,
    "message": "String must contain at least 1 character(s)",
    "path": [
      "playerDataCollection",
      3,
      "name"
    ]
  }
]
ZodError: [
  {
    "code": "too_small",
    "minimum": 1,
    "type": "string",
    "inclusive": true,
    "exact": false,
    "message": "String must contain at least 1 character(s)",
    "path": [
      "pwadCollection",
      0,
      "name"
    ]
  }
]
RoyDefined commented 1 month ago

Another one.

ZodError: [
  {
    "code": "too_big",
    "maximum": 4,
    "type": "number",
    "inclusive": true,
    "exact": false,
    "message": "Number must be less than or equal to 4",
    "path": [
      37,
      "voiceChatType"
    ]
  }
]

This is an issue in general, not just these two specific ones. There should be a way to default to a value if the type is wrong, rather than throwing an error. This issue has more information: https://github.com/colinhacks/zod/issues/1426.

RoyDefined commented 1 month ago

Fixed in 628c2129737cb86b3e787b6737d2cc000ab170d0. Depending on the incoming data there might have to be more catch blocks, but the most apparent ones are now caught.