{"record":{"id":"63a4d05717edfe67","repo":"kovidgoyal/kitty","slug":"failed-to-parse-json-payload-of-remote-command-ig","errorCode":null,"errorMessage":"Failed to parse JSON payload of remote command, ignoring it","messagePattern":"Failed to parse JSON payload of remote command, ignoring it","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kitty/remote_control.py","lineNumber":52,"sourceCode":"\nactive_async_requests: dict[str, float] = {}\nactive_streams: dict[str, str] = {}\nT = TypeVar('T')\nif TYPE_CHECKING:\n    from .window import Window\n\n\ndef encode_response_for_peer(response: Any) -> bytes:\n    return b'\\x1bP@kitty-cmd' + json.dumps(response).encode('utf-8') + b'\\x1b\\\\'\n\n\ndef parse_cmd(serialized_cmd: memoryview, encryption_key: EllipticCurveKey) -> dict[str, Any]:\n    # See https://github.com/python/cpython/issues/74379 for why we cant use\n    # memoryview directly :((\n    try:\n        pcmd = json.loads(bytes(serialized_cmd))\n    except Exception:\n        log_error('Failed to parse JSON payload of remote command, ignoring it')\n        return {}\n    if not isinstance(pcmd, dict) or 'version' not in pcmd:\n        log_error('JSON payload of remote command is invalid, must be an object with a version field')\n        return {}\n    pcmd.pop('password', None)\n    if 'encrypted' in pcmd:\n        if pcmd.get('enc_proto', '1') != RC_ENCRYPTION_PROTOCOL_VERSION:\n            log_error(f'Ignoring encrypted rc command with unsupported protocol: {pcmd.get(\"enc_proto\")}')\n            return {}\n        pubkey = pcmd.get('pubkey', '')\n        if not pubkey:\n            log_error('Ignoring encrypted rc command without a public key')\n        d = AES256GCMDecrypt(encryption_key.derive_secret(base64.b85decode(pubkey)), base64.b85decode(pcmd['iv']), base64.b85decode(pcmd['tag']))\n        data = d.add_data_to_be_decrypted(base64.b85decode(pcmd['encrypted']), True)\n        pcmd = json.loads(data)\n        if not isinstance(pcmd, dict) or 'version' not in pcmd:\n            return {}\n        delta = time_ns() - pcmd.pop('timestamp')","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/remote_control.py#L34-L70","documentation":"An incoming remote-control command (over the socket or via escape sequence) had a payload that is not valid JSON, so parse_cmd discards it. Usually the result of an encrypted payload being sent without decryption or a truncated/garbled message.","triggerScenarios":"@kitty/remotely-control or socket clients sending non-JSON bytes; the raw serialized_cmd fails json.loads in parse_cmd, called from _handle_remote_command.","commonSituations":"Version mismatch between kitten CLI and kitty daemon, a proxy/tool mangling the socket stream, or stray data sent to the remote-control socket.","solutions":["Verify the client and server are the same kitty version","Ensure allow_remote_control is enabled and the client is actually speaking the kitty RC protocol","If using encryption, confirm the payload is wrapped correctly (enc_proto/pubkey fields) rather than raw plaintext"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import json\ndef send_rc(sock, payload: dict):\n    data = json.dumps(payload).encode()\n    sock.sendall(data)  # never send partial/arbitrary bytes","typeGuard":"def is_valid_rc_payload(raw: bytes) -> bool:\n    try:\n        d = json.loads(raw)\n    except Exception:\n        return False\n    return isinstance(d, dict) and 'version' in d","tryCatchPattern":null,"preventionTips":["Always serialize with json.dumps before writing to the RC socket","Keep client/server kitty versions matched"],"tags":["kitty","remote-control","json","socket"],"backgroundTag":"invalid-json-payload","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}