{"record":{"id":"aad4b42bc88672e2","repo":"kovidgoyal/kitty","slug":"the-clipboard-is-empty","errorCode":null,"errorMessage":"The clipboard is empty","messagePattern":"The clipboard is empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kittens/clipboard/read.go","lineNumber":360,"sourceCode":"\t}\n\n\tlp.OnEscapeCode = func(etype loop.EscapeCodeType, data []byte) (err error) {\n\t\tmetadata, payload, err := parse_escape_code(etype, data)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif metadata == nil {\n\t\t\treturn nil\n\t\t}\n\t\tif reading_available_mimes {\n\t\t\tswitch metadata[\"status\"] {\n\t\t\tcase \"DATA\":\n\t\t\t\tavailable_mimes = utils.Map(strings.TrimSpace, strings.Split(utils.UnsafeBytesToString(payload), \" \"))\n\t\t\tcase \"OK\":\n\t\t\tcase \"DONE\":\n\t\t\t\treading_available_mimes = false\n\t\t\t\tif len(available_mimes) == 0 {\n\t\t\t\t\treturn fmt.Errorf(\"The clipboard is empty\")\n\t\t\t\t}\n\t\t\t\tfor _, o := range outputs {\n\t\t\t\t\terr = o.assign_mime_type(available_mimes, aliases)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tif o.remote_mime_type == \".\" {\n\t\t\t\t\t\to.started = true\n\t\t\t\t\t\to.add_data(utils.UnsafeStringToBytes(strings.Join(available_mimes, \"\\n\")))\n\t\t\t\t\t\to.all_data_received = true\n\t\t\t\t\t} else {\n\t\t\t\t\t\trequested_mimes[o.remote_mime_type] = o\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif len(requested_mimes) > 0 {\n\t\t\t\t\tlp.QueueWriteString(encode(basic_metadata, strings.Join(utils.Keys(requested_mimes), \" \")))\n\t\t\t\t} else {\n\t\t\t\t\tlp.Quit(0)","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/clipboard/read.go#L342-L378","documentation":"After querying the peer for the list of available MIME types (DATA ... DONE handshake), an empty list means the clipboard currently holds nothing. The kitten reports 'The clipboard is empty' rather than proceeding to per-output assignment.","triggerScenarios":"`kitten clipboard get`/`getfile` when nothing has ever been copied, or the clipboard was cleared; also when the remote peer reports an empty DATA list (e.g. clipboard cleared on the machine that would serve the data).","commonSituations":"Scripts running right after boot or clipboard-clear operations; reading a remote clipboard over ssh where the remote clipboard daemon has no content; racing with a clipboard manager that clears on focus loss.","solutions":["Copy something first, then retry the get","Verify which machine's clipboard you are reading (local vs remote over ssh) and copy there","Add a retry/empty-check guard in scripts that poll the clipboard"],"exampleFix":"# before\nkitten clipboard get out.txt   # nothing copied yet\n# after\n# copy text in the source app first, then:\nkitten clipboard get out.txt","handlingStrategy":"try-catch","validationCode":"null","typeGuard":null,"tryCatchPattern":"out=$(kitten clipboard get f 2>&1) || { echo \"$out\" | grep -q 'clipboard is empty' && exit 0; exit 1; }  # treat empty as non-error","preventionTips":["Treat empty clipboard as an expected state in polling scripts","Copy before reading; verify you target the right machine's clipboard"],"tags":["kitty","clipboard","empty-state"],"backgroundTag":"empty-clipboard","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}