{"record":{"id":"02c5f6c81f221e2d","repo":"kovidgoyal/kitty","slug":"received-osc-s-packet-from-terminal-with-invalid","errorCode":null,"errorMessage":"Received OSC %s packet from terminal with invalid base64 encoded payload","messagePattern":"Received OSC (.+?) packet from terminal with invalid base64 encoded payload","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/clipboard/read.go","lineNumber":257,"sourceCode":"\tcase \"EPERM\":\n\t\treturn fmt.Errorf(\"permission denied\")\n\tcase \"EBUSY\":\n\t\treturn fmt.Errorf(\"a temporary error occurred, try again later.\")\n\tdefault:\n\t\treturn fmt.Errorf(\"%s\", status)\n\t}\n}\n\nfunc parse_escape_code(etype loop.EscapeCodeType, data []byte) (metadata map[string]string, payload []byte, err error) {\n\tif etype != loop.OSC || !bytes.HasPrefix(data, utils.UnsafeStringToBytes(OSC_NUMBER+\";\")) {\n\t\treturn\n\t}\n\tparts := bytes.SplitN(data, utils.UnsafeStringToBytes(\";\"), 3)\n\tmetadata = make(map[string]string)\n\tif len(parts) > 2 && len(parts[2]) > 0 {\n\t\tpayload, err = base64.StdEncoding.DecodeString(utils.UnsafeBytesToString(parts[2]))\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"Received OSC %s packet from terminal with invalid base64 encoded payload\", OSC_NUMBER)\n\t\t\treturn\n\t\t}\n\t}\n\tif len(parts) > 1 {\n\t\tfor record := range bytes.SplitSeq(parts[1], utils.UnsafeStringToBytes(\":\")) {\n\t\t\trp := bytes.SplitN(record, utils.UnsafeStringToBytes(\"=\"), 2)\n\t\t\tv := \"\"\n\t\t\tif len(rp) == 2 {\n\t\t\t\tv = string(rp[1])\n\t\t\t}\n\t\t\tk := string(rp[0])\n\t\t\tmetadata[k] = unescape_metadata_value(k, v)\n\t\t}\n\t}\n\n\treturn\n}\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/clipboard/read.go#L239-L275","documentation":"Clipboard responses arrive as OSC packets whose payload is base64-encoded. parse_escape_code decodes parts[2] with StdEncoding; on decoding failure it reports an invalid base64 payload, meaning the OSC packet from the terminal was corrupted or malformed.","triggerScenarios":"An OSC 52-style clipboard response whose third ';' separated segment is not valid standard base64 — truncated by terminal line-length limits, mangled by tmux passthrough, or containing URL-safe/whitespace variants StdEncoding rejects.","commonSituations":"tmux or screen wrapping/reflowing long escape sequences; terminal buffer or pty limits truncating giant clipboard payloads; ssh sessions without proper escape passthrough; bugs in terminal emitters that split OSC sequences incorrectly.","solutions":["Enable tmux passthrough properly (set allow-passthrough on) or bypass tmux for the test","Update kitty (and the remote kitten) — sequence splitting bugs were fixed over time","For very large payloads, transfer via file (getfile) instead of inline payloads","Reproduce without intermediaries (direct kitty window) to isolate which layer corrupts the sequence"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"out=$(kitten clipboard get f 2>&1) || { echo \"$out\" | grep -q 'base64' && { sleep 1; kitten clipboard get f; }; }","preventionTips":["Enable tmux allow-passthrough or avoid tmux for clipboard tests","Update kitty; prefer getfile for large payloads"],"tags":["kitty","clipboard","base64","osc-52","corruption"],"backgroundTag":"base64-decode-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}