{"record":{"id":"a0a52d130a57adbb","repo":"kovidgoyal/kitty","slug":"clipboard-write-request-has-more-data-than-allowed","errorCode":null,"errorMessage":"Clipboard write request has more data than allowed by clipboard_max_size ({self.max_size} bytes), ignoring further data","messagePattern":"Clipboard write request has more data than allowed by clipboard_max_size \\((.+?) bytes\\), ignoring further data","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kitty/clipboard.py","lineNumber":356,"sourceCode":"            self.currently_writing_mime = ''\n            if incomplete:\n                # the data is not padded to a multiple of four bytes. This is\n                # tolerated for the legacy OSC 52 protocol as it has no way to\n                # report errors to the client.\n                if self.protocol_type is ProtocolType.osc_5522:\n                    raise self.abort('Incomplete base64 data, missing padding bytes')\n                log_error('Received incomplete data for clipboard')\n\n    def write_base64_data(self, b: bytes | memoryview) -> None:\n        if not self.max_size_exceeded:\n            try:\n                decoded = self.decoder.decode(b)\n            except ValueError as e:\n                raise self.abort(f'Invalid base64 data: {e}') from e\n            if decoded:\n                self.tempfile.write(decoded)\n                if self.max_size > 0 and self.tempfile.tell() > self.max_size:\n                    log_error(f'Clipboard write request has more data than allowed by clipboard_max_size ({self.max_size} bytes), ignoring further data')\n                    self.max_size_exceeded = True\n\n    def data_for(self, mime: str = 'text/plain', offset: int = 0, size: int = -1) -> bytes:\n        start, full_size = self.mime_map[mime]\n        if size == -1:\n            size = full_size\n        return self.tempfile.read(start + offset, size)\n\n\nclass GrantedPermission:\n    one_time: bool = False\n    write_ban: bool = False\n    read_ban: bool = False\n\n    def __init__(self, read: bool = False, write: bool = False, one_time: bool = False):\n        self.read, self.write = read, write\n        self.one_time = one_time\n","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/clipboard.py#L338-L374","documentation":"A clipboard write request exceeded clipboard_max_size; kitty discards the excess data and marks the request as size-exceeded. The remainder of the transfer is ignored.","triggerScenarios":"An app (OSC 52/5522) writes clipboard data larger than the configured `clipboard_max_size` (default 512MB, often lowered). tempfile.tell() exceeds max_size during write_base64_data.","commonSituations":"Users lowering clipboard_max_size to harden kitty, then copying huge images/files; remote sessions tunneling binary clipboard payloads.","solutions":["Raise `clipboard_max_size` in kitty.conf if the large copies are intended","Fix the sender to not push oversized payloads","Keep it as is if the cap is a deliberate security measure"],"exampleFix":"# before\nclipboard_max_size 10000000\n# after\nclipboard_max_size 512000000","handlingStrategy":"validation","validationCode":"size = len(payload)\nfrom kitty.config import defaults  # pseudo\nif size > CLIPBOARD_MAX_SIZE: skip_or_split()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set clipboard_max_size to match your real clipboard payloads","Check payload size before pushing through OSC 52/5522"],"tags":["kitty","clipboard","size-limit","config"],"backgroundTag":"payload-exceeds-size-limit","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}