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

Materialize model during JSON deserialization #255

Merged
merged 2 commits into from
May 23, 2018

Conversation

yifan-coursera
Copy link
Contributor

Previously, deserializing JSON to a courier model resulted in a model that would have lazily initialized fields. This means that if one of the fields was a custom Scala class with custom validation logic in the constructor or coercer, that validation logic would be ignored during deserialization time. Instead, it would run the first time the field was accessed, leading to exceptions thrown at unexpected places. This change forces materialization of the entire model during JSON deserialization time, and causes JSON deserialization to fail if an exception is thrown by the Scala constructor or coercer.

@yifan-coursera yifan-coursera changed the title Materialize JSON parsed bodies Materialize model during JSON deserialization May 23, 2018
@amory-coursera
Copy link
Contributor

Looks good to me. This will really help.

It's likely that we have materialized data instances with invalid field values that slipped through without a check like this. I think we should go ahead with this and enforce validations regardless, but let's make sure to announce this change when it lands in infra-services, and let folks know what they should do if records become unreadable.

@yifan-coursera yifan-coursera merged commit 483dcee into master May 23, 2018
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

Successfully merging this pull request may close these issues.

None yet

2 participants