You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OSHConnect.add_system_to_node / create_and_insert_system silently no-op on an unregistered node #43
OSHConnect.add_system_to_node() and OSHConnect.create_and_insert_system() (oshconnectapi.py:297 and :310) both guard their whole body on if target_node in self._nodes: with no else. When the node isn't registered with the OSHConnect instance, they fall off the end and return None — no exception, no log line. Nothing is POSTed and nothing is attached, but the caller has no way to tell that from a success.
create_and_insert_system() is the worse of the two: its documented return is "the created system", so a caller doing sys = osh.create_and_insert_system(opts, node) gets None and dies later on None.add_insert_datastream(...) — the same class of delayed, misattributed failure as #42, just with a different trigger (the POST is never attempted at all rather than rejected).
Same for osh.add_system_to_node(system, unregistered_node) — returns None and the system is in neither osh.systems() nor node.systems().
Possible fix
Raise on the miss rather than falling through:
iftarget_nodenotinself._nodes:
raiseValueError(
f"Node {target_node.get_id()} is not registered with this "f"OSHConnect instance; call add_node() first."
)
ValueError matches what add_datastream() already raises a few lines up for an unresolvable system id, so it's consistent with the surrounding module. Worth auditing the rest of oshconnectapi.py for the same if …: … return shape while in there.
Activity