Fix crash when a template type has zero typeattrs - #300
Open
knoxsp wants to merge 1 commit into
Open
Conversation
A templatetype with no typeattrs serialises its `typeattrs` as None rather than an empty list. _bulk_add_resource_attrs stored that None directly into typeattr_lookup, and the later `.get(resource_type.id, [])` fallback never applies (the key exists, just mapped to None), so `for ta in typeattrs` crashes with a TypeError on any node/link whose type has no attributes at all (e.g. a plain junction).
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.
Summary
_bulk_add_resource_attrsstorestt.typeattrsintotypeattr_lookupas-is. When a template type has zero typeattrs, that field serialises asNonerather than[].typeattr_lookup.get(resource_type.id, [])fallback doesn't help, since the key exists (just mapped toNone), sofor ta in typeattrsraisesTypeError: 'NoneType' object is not iterable.Fix
Normalise to
[]at the point of storage:typeattr_lookup[tt.id] = tt.typeattrs or [].Test plan