{"record":{"id":"85a0ecac662971db","repo":"kovidgoyal/kitty","slug":"terminal-asked-for-drag-data-from-mime-list-with-o","errorCode":null,"errorMessage":"terminal asked for drag data from MIME list with out of bounds index: %d","messagePattern":"terminal asked for drag data from MIME list with out of bounds index: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/dnd/drag.go","lineNumber":274,"sourceCode":"\t\t\treturn err\n\t\t}\n\t}\n\treturn dnd.render_screen()\n}\n\nfunc (dnd *dnd) finish_drag(errname string) {\n\tif errname == \"\" { // cancel drag\n\t\tdnd.lp.QueueDnDData(DC{Type: 'E', Y: -1})\n\t} else {\n\t\tdnd.lp.QueueDnDData(DC{Type: 'E', Payload: []byte(errname)})\n\t}\n\tdnd.reset_drag()\n}\n\nfunc (dnd *dnd) handle_data_request(idx int) (err error) {\n\tif idx < 0 || idx >= len(dnd.drag_status.offered_mimes) {\n\t\tdnd.finish_drag(\"EINVAL\")\n\t\treturn fmt.Errorf(\"terminal asked for drag data from MIME list with out of bounds index: %d\", idx)\n\t}\n\tmime := dnd.drag_status.offered_mimes[idx]\n\tds := dnd.drag_sources[mime]\n\tfor _, dr := range dnd.drag_status.data_requests {\n\t\tif dr.index == idx {\n\t\t\tdnd.finish_drag(\"EINVAL\")\n\t\t\treturn fmt.Errorf(\"terminal sent a duplicate drag data request\")\n\t\t}\n\t}\n\tdr := &data_request{drag_source: ds, index: idx}\n\tif ds.path == \"\" {\n\t\tdnd.lp.QueueDnDData(DC{Type: 'e', Y: idx, Payload: utils.UnsafeStringToBytes(base64.RawStdEncoding.EncodeToString(ds.data))})\n\t\tdnd.lp.QueueDnDData(DC{Type: 'e', Y: idx}) // EOF\n\t\treturn\n\t} else {\n\t\tif ds.file != nil {\n\t\t\tds.file.Close()\n\t\t}","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/dnd/drag.go#L256-L292","documentation":"During a drag operation the terminal requested drag data by index into the offered MIME list, but the index is negative or >= len(offered_mimes). The kitten aborts the drag with finish_drag(\"EINVAL\") and returns this error.","triggerScenarios":"handle_data_request(idx) is invoked from on_drag_event with an index outside the range of mimes advertised when the drag started — caused by a protocol bug or a desynchronized MIME list between kitten and terminal.","commonSituations":"Version mismatch between the kitten and terminal implementations of the DnD protocol; race where the MIME list changed mid-drag; malformed escape sequence decoding the index.","solutions":["Ensure kitten and kitty terminal come from the same installation/version","Update kitty — index desync is a protocol bug fixed in newer releases","Reproduce with --debug-input and report upstream if persistent"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before starting the drag, assert the offered list is non-empty and stable:\nif len(dnd.drag_status.offered_mimes) == 0 { return errors.New(\"no MIMEs offered\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use matching kitten/terminal versions","Do not mutate the offered MIME list mid-drag"],"tags":["dnd","drag-and-drop","index-out-of-bounds","kitty"],"backgroundTag":"index-out-of-bounds","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}