skip recursion when referenced type is missing from schema list#800
Draft
CamachoJose wants to merge 1 commit intoNetflix:masterfrom
Draft
skip recursion when referenced type is missing from schema list#800CamachoJose wants to merge 1 commit intoNetflix:masterfrom
CamachoJose wants to merge 1 commit intoNetflix:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TypeFilter: skip recursion when referenced type is missing from schema list
Summary
Resolve no longer throws when the schema list omits a type that is referenced by another (object ref, list/set element, or map key/value). The resolver skips recursing into missing types instead of NPEing.
Problem
When building a
TypeFilterwithresolve(schemas), ifschemasis a subset (e.g. from a blob that doesn’t include every referenced type), the resolver can hit a reference whose target type is not in the map. Previously it asserted or used that missing schema and caused an NPE. That happens with optional refs, excluded types, or blobs that only contain a subset of the full schema.Solution
In
Resolver.descendants():refSchema == null, do not recurse; emit(parent, child)and continue.elemSchema == null, do not recurse; emit onlyparent.kSchemaorvSchemais null, useStream.empty()for that branch instead of callingdescendantswith null.No behavioral change when all referenced types are present in the schema list.
Testing
TypeFilterTest.MissingReferencedTypethat resolve against a schema list with some referenced types removed:objectRefMissing_includeRecursive_doesNotThrow)listElementTypeMissing_includeRecursive_doesNotThrow)mapKeyOrValueTypeMissing_includeRecursive_doesNotThrow)excludeRecursive_withMissingRef_doesNotThrow)Use case
Enables consumers to resolve a type filter against a blob’s schema list even when some refs (e.g. optional or excluded types) are not present in that blob, without requiring callers to pre-exclude those types to avoid NPEs.