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:
@@ -31,5 +31,10 @@ func post_json(path: String, body: Dictionary) -> DmResponse:
|
|||||||
var raw: PackedByteArray = signal_args[3]
|
var raw: PackedByteArray = signal_args[3]
|
||||||
if result != HTTPRequest.RESULT_SUCCESS:
|
if result != HTTPRequest.RESULT_SUCCESS:
|
||||||
return DmResponse.failed("transport result %d" % result)
|
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)
|
return DmResponse.ok(response_code, parsed)
|
||||||
|
|||||||
Reference in New Issue
Block a user