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

Optional runtime-checks to prevent unintuitive effects due to schema inheritance #7

Open
apirogov opened this issue Aug 17, 2022 · 0 comments
Labels
enhancement New feature or request internals Technical and subtle issues users are (usually) not aware of

Comments

@apirogov
Copy link
Collaborator

apirogov commented Aug 17, 2022

When packing a container, it should be ensured that at each node following property holds:

Parent compatibility: Each attached metadata object can be parsed as all parent/ancestor types
Parent consistency: Two objects for two schemas sharing some parent schema should agree on the parent-parse of the objects

The first one is crucial for the granular query to work correctly at all, and should also be checked in tests by schema developers.

The second one is required to avoid "undefined behavior" when asking for an object of a more general type (it might be surprising that you get "any" suitable child and if they don't agree, ultimately get different metadata), and this cannot be checked as it is instance-dependent.

Doing this during MetadorContainer modifications adds some little overhead during container creation, but could catch mistakes and assuming that a container is mostly read and usually created once, is very worth it.

On modifications of metadata:

  • For parent compatibility, could parse a new object with all parent schemas to verify that it actually works

Parent compatibility should be covered in test cases, but these are never perfect. This would give a guarantee for the concrete instance that it actually works.

  • For parent consistency, need to parse the new object with all parent types where another subclass instance is attached and check equality with parse from one alternative existing object.

This would work, assuming the existing metadata is already consistent (otherwise every "bundle" needs to be checked, this would be more expensive, but of course possible when doing a consistency check of an existing container)

@apirogov apirogov added the idea label Aug 17, 2022
@apirogov apirogov added enhancement New feature or request and removed idea labels Sep 20, 2022
@apirogov apirogov added the internals Technical and subtle issues users are (usually) not aware of label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request internals Technical and subtle issues users are (usually) not aware of
Projects
None yet
Development

No branches or pull requests

1 participant