From 201b2c5e52c9910931e05849a34fcfe006783a61 Mon Sep 17 00:00:00 2001 From: kzangeli Date: Thu, 28 May 2026 20:24:13 +0200 Subject: [PATCH] fix(D010_01_aux): JSON-serialise stub body (HttpCtrl does not auto-encode dicts) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test passed `${entity_body}` straight to `Set Stub Reply`, but `Load Entity` returns a Python dict and HttpCtrl's response writer (`http_handler.py::__send_response`) only encodes the body when it is already a `str`. A dict falls through: `len(dict)` reports the number of keys (wrong `Content-Length`) and `wfile.write(dict)` raises silently, so the mock sends headers only. That made the auxiliary RetrieveEntity merge look broken — the broker received no upstream body to gap-fill from. Verified end-to-end against a real upstream: § 9.3.2 aux gap-fill works (local wins for shared attrs, CSR fills the gap). Serialise the body to a JSON string before passing to `Set Stub Reply` so the wire payload is non-empty. Verified: `D010_01_aux` passes. --- .../Consumption/Entity/RetrieveEntity/D010_01_aux.robot | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/TP/NGSI-LD/DistributedOperations/Consumption/Entity/RetrieveEntity/D010_01_aux.robot b/TP/NGSI-LD/DistributedOperations/Consumption/Entity/RetrieveEntity/D010_01_aux.robot index 0922214d..e5149d91 100644 --- a/TP/NGSI-LD/DistributedOperations/Consumption/Entity/RetrieveEntity/D010_01_aux.robot +++ b/TP/NGSI-LD/DistributedOperations/Consumption/Entity/RetrieveEntity/D010_01_aux.robot @@ -28,7 +28,13 @@ D010_01_aux Retrieve Entity That Exists On Both The Context Source And The Conte [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-auxiliary 4_3_6_2 5_7_1 ${entity_body}= Load Entity ${entity_payload_filename} ${entity_id} ${entity_fragment}= Load JSON From File ${EXECDIR}/data/entities/fragmentEntities/${fragment_filename} - Set Stub Reply GET /ngsi-ld/v1/entities/${entity_id} 200 ${entity_body} + # `Load Entity` returns a Python dict; HttpCtrl's `Set Stub Reply` writes + # the body argument verbatim and does NOT auto-serialise non-string values + # (a dict passed straight in: `len(dict)` reports the key count for the + # Content-Length header, and `wfile.write(dict)` raises silently — the + # mock ends up sending headers only). Serialise to a JSON string first. + ${entity_body_json}= Evaluate json.dumps($entity_body) json + Set Stub Reply GET /ngsi-ld/v1/entities/${entity_id} 200 ${entity_body_json} ${response}= Retrieve Entity ${entity_id} context=${ngsild_test_suite_context} Check Response Status Code 200 ${response.status_code} -- GitLab