-
Notifications
You must be signed in to change notification settings - Fork 33
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
Deserialization of unknown enum value #277
Comments
Hi @HaydnDias
where-as the following languages will throw: We could see two different ways: it's better to quietly fail as it doesn't break the application right away, but it might derail its logic. Or no, it's better to fail loudly so people know they need to update their code. Before we take any action on that (alignment will be required either way), I'd like @darrelmiller opinion on the matter. |
@baywet Hey! Yeah we're adopting Kiota for one of our core libraries, we actually found some other concerns, I think it is likely the case that the provided I agree there are two different ways, could it be that we have two For us we want loud sirens for when something fails to deserialize, we've modified your provided Some notable changes are, removing safety around It's not a final, we have more testing to do, but I think it's fair to say we want a stricter parser, with allowances for some things like Appreciate all the work you do on Kiota, I forsee us using it heavily and hope we get time to contribute back with PRs rather than just issues! |
a) Yes we need to align across languages Something like this: Address.Rules = new[]
{
(address) => address.Street == null ? throw new ArgumentException("Street is required") : null,
(address) => address.Type == null ? throw new ArgumentException("Type is required") : null,
}; |
Transferring issue as part of #238 |
Hello!
Whilst testing we found a regression after switching from nswag -> kiota, we used to get a
Newtonsoft.Json.JsonSerializationException
when we deserialized an entity with an unknown enum value, it'd give us an error likeError converting value "EXAMPLE_ENUM_STRING_VALUE" to type 'System.Nullable`1[Example.Project.Models.ExampleEnum]'.
.With kiota, the
JsonParseNode
returns null if it can't parse it, I know we can implement our ownIParseNode
andIParseNodeFactory
for this, however it does seem wastefulhaving to have a copy of the entireJsonParseNode
class for what is effectively a one line change, and it means that we'll need to keep our implementation up to date with changes made here if we want to keep it as close to the default implementation as possible.Currently we've made a change to GetEnumValue as below:
Reasoning for this is we'd like to catch and log when we receive a new enum value as sometimes third parties do add new ones without telling us and we need to be aware.
What are your thoughts on potential solutions to adding something official to be able to handle cases like this?
The text was updated successfully, but these errors were encountered: