fix(client): parse HttpTransport body via JSON.new() not parse_string

Whole-branch review Minor #1: JSON.parse_string pushes an engine-level
error on a non-JSON body (e.g. a gateway HTML 502), which the project's
gutconfig promotes to a false failure — the same reason FallbackLibrary
already avoids it. Consistency fix; a non-JSON body still degrades.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-10 10:20:26 -05:00
parent 89afd85bb2
commit 23ccc799aa

View File

@@ -31,5 +31,10 @@ func post_json(path: String, body: Dictionary) -> DmResponse:
var raw: PackedByteArray = signal_args[3]
if result != HTTPRequest.RESULT_SUCCESS:
return DmResponse.failed("transport result %d" % result)
var parsed = JSON.parse_string(raw.get_string_from_utf8()) # null if not JSON
# Parse via JSON.new() rather than JSON.parse_string(): the latter pushes an
# engine-level error on a non-JSON body (e.g. a gateway's HTML 502), which the
# project's gutconfig promotes to a false test failure. A non-JSON body stays
# null here — the service treats a non-dict body as a failure and degrades.
var json := JSON.new()
var parsed = null if json.parse(raw.get_string_from_utf8()) != OK else json.data
return DmResponse.ok(response_code, parsed)