Skip to content

Fix crash when a template type has zero typeattrs - #300

Open
knoxsp wants to merge 1 commit into
masterfrom
fix-none-typeattrs-in-bulk-add-resource-attrs
Open

Fix crash when a template type has zero typeattrs#300
knoxsp wants to merge 1 commit into
masterfrom
fix-none-typeattrs-in-bulk-add-resource-attrs

Conversation

@knoxsp

@knoxsp knoxsp commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • _bulk_add_resource_attrs stores tt.typeattrs into typeattr_lookup as-is. When a template type has zero typeattrs, that field serialises as None rather than [].
  • The later typeattr_lookup.get(resource_type.id, []) fallback doesn't help, since the key exists (just mapped to None), so for ta in typeattrs raises TypeError: 'NoneType' object is not iterable.
  • This hits any network containing a node/link whose type has no attributes at all (e.g. a plain junction).

Fix

Normalise to [] at the point of storage: typeattr_lookup[tt.id] = tt.typeattrs or [].

Test plan

  • Reproduced against a local sqlite-backed hydra_base instance importing a network containing plain junction nodes; confirmed the crash without the fix and the successful import with it.

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).
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.

2 participants