maofalt / Transcendence

4 stars 0 forks source link

Lack of validation for API match settings. #109

Closed maofalt closed 6 months ago

maofalt commented 7 months ago

Lack of validation for API match settings. Shoudl this be valdiated in the front-end ? back-end (tournament or match?)? When the GetGame Settings are completely wrongly iwe just have a 500 error, instead of a descriptive one. Hypothesis '; there is no valdiation on the backend.

do we check if the number of players are the samas the PlayersDAta ? This allows me launcha game "gamemodeData": { "nbrOfPlayers": 1, "nbrOfRounds": 1, "timeLimit": 0 }, "fieldData": { "wallsFactor": 1, "sizeOfGoals": 20 }, "paddlesData": { "width": 2, "height": 12, "speed": 0.5 }, "ballData": { "speed": 0.7, "radius": 1, "color": "0xffffff" }, "playersData": [ { "accountID": "tata", "color": "0x0000ff" }, { "accountID": "player2", "color": "0x00ff00" },

image

As well input nbr of players as a negative or null nbr responds witht he incorrect error code .

Inputting twice the same accountID breakes the game as well

YoelRidgway commented 7 months ago

Yes I will add validation when creating the match and return a valid response. If we want to have better user experience we can also add validation on the front end as well, but the createMatch endpoint needs to be protected because currently it crashes the backend on a malformed post body or invalid settings.

YoelRidgway commented 6 months ago

This was fixed by Zachary. If there are more problems with the endpoints we can create new issues in the future.