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

Enums with many variants break deserialization of incorrect data #120

Open
MStarha opened this issue Dec 21, 2023 · 2 comments
Open

Enums with many variants break deserialization of incorrect data #120

MStarha opened this issue Dec 21, 2023 · 2 comments

Comments

@MStarha
Copy link

MStarha commented Dec 21, 2023

I have an enum with many variants with variable sizes. If there is 72 variants and fewer and I pass invalid bytes to the deserializer, it correctly reports the data cannot be deserialized. However, if there are more than 72 variants and I pass invalid bytes, the deserializer returns the 73rd enum variant regardless of how many variants there are or what the variant contains.

I cannot say whether the mistake is in serde or postcard because I cannot get to the derived implementation of Deserialize for my enum.

Is there anything I can do? Maybe use flavors?

I know 70+ variants is a lot, those are commands my application can receive and react to. I do not think I can realistically reduce the number. I am not sure that any of my code can help here.

Thank you.

@jamesmunns
Copy link
Owner

Hey @MStarha, could you please provide some kind of github repo or gist with a minimal reproduction case showing this behavior?

@MStarha
Copy link
Author

MStarha commented Feb 19, 2024

Since posting I switched to ciborium and the issue went away. I am now very strapped for time and cannot make an example. I'll try to remember later.

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

2 participants