Skip to content

Commit 1b46b75

Browse files
improve: remove debug scaffolding and double-serialization from WindowsNodeClient (#150)
- Remove verbose debug block in SendNodeConnectAsync that logged sensitive data (auth token prefix, Ed25519 signature, full connect payload) on every connect attempt; this ran in all builds, not just debug. - Eliminate redundant BuildDebugPayload() call (was called twice: once for logging, once inside SignPayload) — only the SignPayload call remains. - Remove duplicate JSON serialization: msg was serialized twice (once with WriteIndented for the debug log, once compact to actually send); collapse to a single compact serialization and remove the now-unused s_indentedOptions field. - Remove HandleResponse debug log that allocated a full payload string just to truncate it for a Debug()-level message. No functional change; connection, signing, and registration behaviour are identical. Test status: 525 Shared passed, 99 Tray passed. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <[email protected]>
1 parent 5b57ebd commit 1b46b75

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/OpenClaw.Shared/WindowsNodeClient.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class WindowsNodeClient : WebSocketClientBase
3131
{
3232
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
3333
};
34-
private static readonly JsonSerializerOptions s_indentedOptions = new() { WriteIndented = true };
34+
3535
private static readonly Regex s_commandValidator = new(@"^[a-zA-Z0-9._-]+$", RegexOptions.Compiled);
3636

3737
// Events
@@ -357,21 +357,7 @@ private async Task SendNodeConnectAsync(string? nonce, long ts)
357357
{
358358
try
359359
{
360-
// Sign the payload - INCLUDE the auth token in the payload!
361-
var debugPayload = _deviceIdentity.BuildDebugPayload(nonce, signedAt, ClientId, authToken);
362360
signature = _deviceIdentity.SignPayload(nonce, signedAt, ClientId, authToken);
363-
364-
// Full debug output for verification
365-
_logger.Debug("=== Debug Info ===");
366-
_logger.Debug($"Device ID: {_deviceIdentity.DeviceId}");
367-
_logger.Debug($"Public Key: {_deviceIdentity.PublicKeyBase64Url}");
368-
_logger.Debug($"Client ID: {ClientId}");
369-
_logger.Debug($"Auth Token (in payload): {authToken?.Substring(0, Math.Min(16, authToken?.Length ?? 0))}...");
370-
_logger.Debug($"Nonce: {nonce}");
371-
_logger.Debug($"SignedAt: {signedAt}");
372-
_logger.Debug($"Payload: {debugPayload.Substring(0, Math.Min(100, debugPayload.Length))}...");
373-
_logger.Debug($"Signature: {signature}");
374-
_logger.Debug("==================");
375361
}
376362
catch (Exception ex)
377363
{
@@ -418,26 +404,18 @@ private async Task SendNodeConnectAsync(string? nonce, long ts)
418404
}
419405
};
420406

421-
var json = JsonSerializer.Serialize(msg, s_indentedOptions);
422-
_logger.Debug($"[NODE TX FULL JSON]:\n{json}");
423-
await SendRawAsync(JsonSerializer.Serialize(msg)); // Send compact version
407+
await SendRawAsync(JsonSerializer.Serialize(msg));
424408
_logger.Info($"Sent node registration with device ID: {_deviceIdentity.DeviceId.Substring(0, 16)}..., paired: {isPaired}");
425409
}
426410

427411
private void HandleResponse(JsonElement root)
428412
{
429-
// DEBUG: Log entire response structure
430-
_logger.Debug($"[NODE] HandleResponse - ok: {(root.TryGetProperty("ok", out var okVal) ? okVal.ToString() : "missing")}");
431-
432413
if (!root.TryGetProperty("payload", out var payload))
433414
{
434415
_logger.Warn("[NODE] Response has no payload");
435416
return;
436417
}
437418

438-
var payloadText = payload.ToString();
439-
_logger.Debug($"[NODE] Response payload: {payloadText.Substring(0, Math.Min(200, payloadText.Length))}...");
440-
441419
// Handle hello-ok (successful registration)
442420
if (payload.TryGetProperty("type", out var t) && t.GetString() == "hello-ok")
443421
{

0 commit comments

Comments
 (0)