Problem
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).
Reproduce
osh = OSHConnect(name="demo")
node = Node(protocol="http", address="localhost", port=8282) # never osh.add_node(node)
sys = osh.create_and_insert_system({"label": "S", "urn": "urn:x:1"}, node)
assert sys is None # silently
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:
if target_node not in self._nodes:
raise ValueError(
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.
Related: #42 (same silent-failure family, POST-rejected trigger).
Problem
OSHConnect.add_system_to_node()andOSHConnect.create_and_insert_system()(oshconnectapi.py:297and:310) both guard their whole body onif target_node in self._nodes:with noelse. When the node isn't registered with theOSHConnectinstance, they fall off the end and returnNone— 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 doingsys = osh.create_and_insert_system(opts, node)getsNoneand dies later onNone.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).Reproduce
Same for
osh.add_system_to_node(system, unregistered_node)— returnsNoneand the system is in neitherosh.systems()nornode.systems().Possible fix
Raise on the miss rather than falling through:
ValueErrormatches whatadd_datastream()already raises a few lines up for an unresolvable system id, so it's consistent with the surrounding module. Worth auditing the rest ofoshconnectapi.pyfor the sameif …: … returnshape while in there.Related: #42 (same silent-failure family, POST-rejected trigger).