{"record":{"id":"146033bfb0fe3a8d","repo":"kovidgoyal/kitty","slug":"malformed-osc-5522-metadata-is-not-key-value-pair","errorCode":null,"errorMessage":"Malformed OSC 5522: metadata is not key=value pairs","messagePattern":"Malformed OSC 5522: metadata is not key=value pairs","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kitty/clipboard.py","lineNumber":399,"sourceCode":"        self.osc52_in_flight_write_requests: dict[ClipboardType, WriteRequest] = {}\n        self.granted_passwords: dict[str, GrantedPermission] = {}\n\n    def parse_osc_5522(self, data: memoryview) -> None:\n        from .notifications import sanitize_id\n\n        idx = find_in_memoryview(data, ord(b';'))\n        if idx > -1:\n            metadata = str(data[:idx], 'utf-8', 'replace')\n            epayload = data[idx + 1 :]\n        else:\n            metadata = str(data, 'utf-8', 'replace')\n            epayload = data[len(data) :]\n        m: dict[str, str] = {}\n        for record in metadata.split(':'):\n            try:\n                k, v = record.split('=', 1)\n            except Exception:\n                log_error('Malformed OSC 5522: metadata is not key=value pairs')\n                return\n            m[k] = v\n        typ = m.get('type', '')\n        try:\n            m = {k: decode_metadata_value(k, v) for k, v in m.items()}\n        except Exception as e:\n            log_error(f'Malformed OSC 5522: could not decode a metadata value. Error: {e}')\n            if typ in ('wdata', 'walias') and self.in_flight_write_request is not None:\n                self.abort_write_request(self.in_flight_write_request, 'EINVAL')\n            return\n        if typ == 'read':\n            try:\n                mime_types = tuple(strict_base64_decode(epayload).decode('utf-8').split())\n            except Exception as e:\n                log_error(f'Malformed OSC 5522: read request payload is not valid base64 encoded UTF-8. Error: {e}')\n                return\n            rr = ReadRequest(\n                is_primary_selection=m.get('loc', '') == 'primary',","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/clipboard.py#L381-L417","documentation":"An OSC 5522 clipboard control sequence's metadata section could not be split into key=value records; kitty logs and drops the whole message.","triggerScenarios":"parse_osc_5522 receives metadata where a record lacks '=' (e.g. 'type:wdata' instead of 'type=wdata'), so record.split('=',1) fails to unpack.","commonSituations":"Hand-rolled clients or probes of the kitty clipboard protocol using ':' as the kv separator instead of '='; truncated sequences.","solutions":["Fix the client to use '=' between key and value, ':' between records","Send well-formed OSC 5522: metadata records like type=wdata:loc=clipboard"],"exampleFix":"# before\n\\x1b]5522;type:wdata\\x1b\\\\\n# after\n\\x1b]5522;type=wdata\\x1b\\\\","handlingStrategy":"validation","validationCode":"def valid_meta(metadata: str) -> bool:\n    return all('=' in rec for rec in metadata.split(':'))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use '=' for key=value and ':' as record separator in OSC 5522 metadata","Test protocol encodings against kitty's docs before shipping"],"tags":["kitty","clipboard","osc5522","protocol","parsing"],"backgroundTag":"protocol-message-malformed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}