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

fix(proto_optional_fields): loosen schema validators to only check fo… #381

Merged
merged 2 commits into from
May 24, 2024

Conversation

jsdonn
Copy link
Contributor

@jsdonn jsdonn commented May 23, 2024

…r existence of previously required fields

Summary

Doc with more context and info: https://docs.google.com/document/d/1_yFcP8PWHEvrgpTLA_7fAYsxBlqQrBDQfD6J18DC7jE/edit?usp=sharing

Tl;dr: Due to LI's Protobuf migration, the "required" concept is no longer available in Proto3 (versus PDL). GMA previously relies on schema validators to check that model definitions contain certain required fields, notably "urn" and "aspects" fields. As such, the schema validation check requirements must be loosened to support the transition to Proto3.

For all cases where schema validation happens, do a check to make sure that the previously required field indeed exists, but do not check if it's an optional or required field. In the case that an expected field does not even exist, throw an InvalidSchemaException.

Where possible, enforce that the "urn" and "aspects" fields are non-null. These runtime checks will help to ensure that bad data does not get ingested or created. In the case that a non-null field is found to be null, throw a NullFieldException.

Testing Done

Unit tests are added to cover all of the new use cases where null fields or missing fields could happen.

Checklist

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 54.83871% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 67.57%. Comparing base (c79500a) to head (2b34a36).

Files Patch % Lines
...va/com/linkedin/metadata/dao/utils/ModelUtils.java 54.83% 7 Missing and 7 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #381      +/-   ##
============================================
- Coverage     67.74%   67.57%   -0.17%     
  Complexity     1343     1343              
============================================
  Files           132      132              
  Lines          5276     5293      +17     
  Branches        546      553       +7     
============================================
+ Hits           3574     3577       +3     
- Misses         1484     1491       +7     
- Partials        218      225       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jsdonn jsdonn marked this pull request as ready for review May 24, 2024 01:27
Copy link
Contributor

@zhixuanjia zhixuanjia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jsdonn jsdonn merged commit 3121767 into linkedin:master May 24, 2024
2 checks passed
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.

3 participants