http sender drops reply keys no output port declares
A sender without outputs no longer fails on a {"status": "ok"} reply.
This commit is contained in:
@@ -301,7 +301,7 @@ class HttpNode(Node):
|
||||
:type params: dict
|
||||
:param kwargs: Pipeline data to send (from required messages).
|
||||
:type kwargs: Any
|
||||
:returns: Response data if the endpoint returns JSON, None otherwise.
|
||||
:returns: The reply's values for the declared output ports, or None.
|
||||
:rtype: dict | None
|
||||
"""
|
||||
client = shared_client()
|
||||
@@ -330,8 +330,13 @@ class HttpNode(Node):
|
||||
except Exception:
|
||||
return None
|
||||
# Outputs are keyed by port, so only an object can be one. A bare
|
||||
# scalar or list is a valid reply, just not something to publish.
|
||||
return body if isinstance(body, dict) else None
|
||||
# scalar or list is a valid reply, just not something to publish,
|
||||
# and neither is a key no port declares: the reply is the
|
||||
# endpoint's, and a `status` beside the values is common.
|
||||
if not isinstance(body, dict):
|
||||
return None
|
||||
ports = {spec.port for spec in self.output_ports}
|
||||
return {key: value for key, value in body.items() if key in ports} or None
|
||||
|
||||
except httpx.HTTPStatusError as e:
|
||||
logger.error(
|
||||
|
||||
Reference in New Issue
Block a user