HttpCtrl: set_stub_reply must not double-encode str/bytes bodies
The vendored 0.3.1 fork has:
response = Response(int(status), None, json.dumps(body), None, None)
— body is always passed through json.dumps(). This was presumably
added to fix the opposite bug (dict bodies served raw to the wire — see
MR !273 (merged) / D010_01_aux). But callers that already pass a serialised JSON
string (e.g. via Convert JSON To String in JsonUtils.resource) now
get their body double-encoded: a Python str of '[{"id":"X"}]' becomes
the wire body '"[{\\"id\\":\\"X\\"}]"' — a JSON string wrapping the
intended JSON array. The broker's response parser sees a String where it
expects an Array, and the merge silently fails.
Conditional auto-serialisation handles both cases:
if not isinstance(body, (str, bytes)) and body is not None:
body = json.dumps(body)
response = Response(int(status), None, body, None, None)
Verified: D011_02_exc_01 (which was failing as "missing $.speed") now
passes; full distops sub-suite shows ~9 tests flipping from FAIL→PASS.
The earlier D010_01_aux test-side workaround (Evaluate json.dumps( $entity_body)) remains harmless (re-json.dumps-ing a string just
returns the same string), so MR !273 (merged) needs no follow-up.
Documented as testsuite-doubts.md #77 (closed).