Description
In api/entities/entity_encoder.py:7, encode_node removes the 'Searchable' label from the node object:
def encode_node(n: Node) -> dict:
n.labels.remove('Searchable')
return vars(n)
This modifies the original node in place. Encoding the same node twice will raise ValueError because 'Searchable' is already removed on the second call.
Impact
- Encoding a node is destructive — the original node object loses the label
- Encoding the same node twice crashes with
ValueError: list.remove(x): x not in list
Suggested Fix
Create a copy of the labels instead of modifying in place:
def encode_node(n: Node) -> dict:
result = vars(n).copy()
result['labels'] = [l for l in n.labels if l != 'Searchable']
return result
Context
Found during code review of PR #522.
Description
In
api/entities/entity_encoder.py:7,encode_noderemoves the'Searchable'label from the node object:This modifies the original node in place. Encoding the same node twice will raise
ValueErrorbecause'Searchable'is already removed on the second call.Impact
ValueError: list.remove(x): x not in listSuggested Fix
Create a copy of the labels instead of modifying in place:
Context
Found during code review of PR #522.