Closed ElenaSotoSobrino closed 3 months ago
There are more than one instance of a such buggy game: id: 664e159f7d4305b118a4f48a id: 664dfc707d4305b118a4a4e0 id: 664df2647d4305b118a4733d
I have deleted some but someone keeps creating more. I have changed the string
user password to see who is the culprit.
I have found some configuration for the Jackson
Deserializer we are using that allows to fix this issue to some extent.
The Sollution is enabling ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT
see the code below.
@Module
public class MainModule {
@Provides
@Singleton
ObjectMapper mapper() {
return new ObjectMapper()
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.setSerializationInclusion(JsonInclude.Include.NON_ABSENT)
.enable(SerializationFeature.INDENT_OUTPUT)
// This Line can help.
.enable(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT);
}
}
Describe the bug In the Game model of the server is an attribute "settings" which should be an integer. But somehow another user of this server created a game with "settings" as an empty array. Now if we are loading all Games, there will be an error because an array cannot be converted to an integer.
The Game has following attributes: "_id": "664df2647d4305b118a4733d", "name": "default", "owner": "662b83dea51a788b23a74d4b", "started": false, "speed": 1, "period": 0, "settings": [], "createdAt": "2024-05-22T13:25:56.541Z", "updatedAt": "2024-05-22T13:25:56.541Z", "members": 1
Expected behavior Please delete this game and try to fix this, so user cannot create a game with setting with typ array