stanford-oval/storm · error · Exception
Insert node error. Node {child_node_name} already exists und
Error message
Insert node error. Node {child_node_name} already exists under its parent node {self.name}. What it means
KnowledgeNode.add_child refuses to insert a child whose name already exists under the node when duplicate_handling is 'raise error' (the default strict mode); 'skip' instead returns the existing child.
Source
Thrown at knowledge_storm/dataclass.py:150
def has_child(self, child_node_name: str):
"""
Check if the node has the child of given name.
"""
return child_node_name in [child.name for child in self.children]
def add_child(self, child_node_name: str, duplicate_handling: str = "skip"):
"""
Adds a child node to the current node.
duplicate_handling (str): How to handle duplicate nodes. Options are "skip", "none", and "raise error".
"""
if self.has_child(child_node_name):
if duplicate_handling == "skip":
for child in self.children:
if child.name == child_node_name:
return child
elif duplicate_handling == "raise error":
raise Exception(
f"Insert node error. Node {child_node_name} already exists under its parent node {self.name}."
)
child_node = KnowledgeNode(name=child_node_name, parent=self)
self.children.append(child_node)
return child_node
def get_parent(self):
"""
Returns the parent node of the current node.
Returns:
KnowledgeNode: The parent node of the current node.
"""
return self.parent
def get_children(self):
"""
Returns the children of the current node.View on GitHub (pinned to fb951af774)
Solutions
- Pass duplicate_handling='skip' to reuse the existing node
- Normalize names (strip/casefold) before inserting
- Check node.has_child(name) first and reuse the existing child
Example fix
# before
node.add_child('History') # raises if 'History' exists
# after
child = node.add_child('History', duplicate_handling='skip') Defensive patterns
Strategy: validation
Validate before calling
if node.has_child(name):
child = next(c for c in node.children if c.name == name)
else:
child = node.add_child(name) Try / catch
try:
child = node.add_child(name)
except Exception as e:
if 'already exists' not in str(e):
raise
child = node.add_child(name, duplicate_handling='skip') Prevention
- Use duplicate_handling='skip' for idempotent inserts
- Normalize names before insertion
- Check has_child before add_child
When it happens
Trigger: Calling add_child (directly or via insert_node/find_node_by_path) with a name that has_child() already reports, while duplicate_handling='raise error'.
Common situations: Inserting information whose computed node name collides with an existing node (case differences, trailing whitespace), or re-running insertion over an already-populated knowledge base without dedup.
AI-assisted analysis of stanford-oval/storm@fb951af774 (2026-08-28).
Data as JSON: /api/errors/47c286d0937ab90d.
Report an issue: GitHub.