Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum parsing. Use default value. #10

Open
brexGmbH opened this issue Apr 18, 2023 · 0 comments
Open

Enum parsing. Use default value. #10

brexGmbH opened this issue Apr 18, 2023 · 0 comments

Comments

@brexGmbH
Copy link

Hi,
Luckily right before a big release we noticed a big problem in conversions with enums.
The problem is the following:
Lets assume we have an enum with the following values:

PlayerType: {Unknown, Player 1, Player 2, Player 3}
We created a struct that has these 4 options as well.
Now we release that version with the struct containing those 4 options.
After that we decide to implement a 4th player type (Player 4).
In the backend we add that player type, but our users still run the "old" unreal software.
These old clients receive a json response from the backend that can say PlayerType = Player 4.

If that is actually the case the plugin will throw an error and json2struct conversion fails completely, even if this was just one little thing in a big nested struct. We need it to use a default value instead, so we can handle unknown players.

I fixed it by only throwing a warning instead of aborting.
In my fix it will always choose the first enum value in this case.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant