From 04c33fa0615a12ff70daae0ff874d578a3bff91e Mon Sep 17 00:00:00 2001 From: Frank Yang Date: Wed, 11 Mar 2026 18:25:24 +0800 Subject: [PATCH] fix: harden mac browser proxy regression test openclaw#43069 thanks @Effet --- CHANGELOG.md | 1 + .../MacNodeBrowserProxyTests.swift | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1edb0770e3a..0a9621f96da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -165,6 +165,7 @@ Docs: https://docs.openclaw.ai - Auth/profile resolution: log debug details when auto-discovered auth profiles fail during provider API-key resolution, so `--debug` output surfaces the real refresh/keychain/credential-store failure instead of only the generic missing-key message. (#41271) thanks @he-yufeng. - ACP/cancel scoping: scope `chat.abort` and shared-session ACP event routing by `runId` so one session cannot cancel or consume another session's run when they share the same gateway session key. (#41331) Thanks @pejmanjohn. - SecretRef/models: harden custom/provider secret persistence and reuse across models.json snapshots, merge behavior, runtime headers, and secret audits. (#42554) Thanks @joshavant. +- macOS/browser proxy: serialize non-GET browser proxy request bodies through `AnyCodable.foundationValue` so nested JSON bodies no longer crash the macOS app with `Invalid type in JSON write (__SwiftValue)`. (#43069) Thanks @Effet. ## 2026.3.7 diff --git a/apps/macos/Tests/OpenClawIPCTests/MacNodeBrowserProxyTests.swift b/apps/macos/Tests/OpenClawIPCTests/MacNodeBrowserProxyTests.swift index a044025562f..b341263b21f 100644 --- a/apps/macos/Tests/OpenClawIPCTests/MacNodeBrowserProxyTests.swift +++ b/apps/macos/Tests/OpenClawIPCTests/MacNodeBrowserProxyTests.swift @@ -39,9 +39,21 @@ struct MacNodeBrowserProxyTests { #expect(tabs[0]["id"] as? String == "tab-1") } - // Regression test: POST body with nested AnyCodable must not crash with __SwiftValue + // Regression test: nested POST bodies must serialize without __SwiftValue crashes. @Test func postRequestSerializesNestedBodyWithoutCrash() async throws { - var capturedBody: Data? + actor BodyCapture { + private var body: Data? + + func set(_ body: Data?) { + self.body = body + } + + func get() -> Data? { + self.body + } + } + + let capturedBody = BodyCapture() let proxy = MacNodeBrowserProxy( endpointProvider: { MacNodeBrowserProxy.Endpoint( @@ -50,7 +62,7 @@ struct MacNodeBrowserProxyTests { password: nil) }, performRequest: { request in - capturedBody = request.httpBody + await capturedBody.set(request.httpBody) let url = try #require(request.url) let response = try #require( HTTPURLResponse( @@ -64,7 +76,7 @@ struct MacNodeBrowserProxyTests { _ = try await proxy.request( paramsJSON: #"{"method":"POST","path":"/action","body":{"nested":{"key":"val"},"arr":[1,2]}}"#) - let bodyData = try #require(capturedBody) + let bodyData = try #require(await capturedBody.get()) let parsed = try #require(JSONSerialization.jsonObject(with: bodyData) as? [String: Any]) let nested = try #require(parsed["nested"] as? [String: Any]) #expect(nested["key"] as? String == "val")