Skip to content

Comments

skip recursion when referenced type is missing from schema list#800

Draft
CamachoJose wants to merge 1 commit intoNetflix:masterfrom
CamachoJose:feature/missing-ref
Draft

skip recursion when referenced type is missing from schema list#800
CamachoJose wants to merge 1 commit intoNetflix:masterfrom
CamachoJose:feature/missing-ref

Conversation

@CamachoJose
Copy link

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 TypeFilter with resolve(schemas), if schemas is 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():

  • OBJECT: If refSchema == null, do not recurse; emit (parent, child) and continue.
  • SET/LIST: If elemSchema == null, do not recurse; emit only parent.
  • MAP: If kSchema or vSchema is null, use Stream.empty() for that branch instead of calling descendants with null.

No behavioral change when all referenced types are present in the schema list.

Testing

  • New tests in TypeFilterTest.MissingReferencedType that resolve against a schema list with some referenced types removed:
    • Object ref missing (objectRefMissing_includeRecursive_doesNotThrow)
    • List element type missing (listElementTypeMissing_includeRecursive_doesNotThrow)
    • Map key type missing (mapKeyOrValueTypeMissing_includeRecursive_doesNotThrow)
    • Recursive exclude with missing ref (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.

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.

1 participant