kovidgoyal/kitty · warning

Failed to read requested mime type {mime} with error: {e}

Error message

Failed to read requested mime type {mime} with error: {e}

What it means

While fulfilling a clipboard read request, reading the requested MIME type from the clipboard provider (cp.get_mime) raised; kitty logs it and continues with the remaining MIME types, ending the response with DONE.

Source

Thrown at kitty/clipboard.py:681

        def write_chunks(data: bytes) -> None:
            assert w is not None
            mv = memoryview(data)
            while mv:
                w.screen.send_escape_code_to_child(ESC_OSC, rr.encode_response(payload=mv[:READ_RESPONSE_CHUNK_SIZE], mime=current_mime))
                mv = mv[READ_RESPONSE_CHUNK_SIZE:]

        for mime in rr.mime_types:
            current_mime = mime
            if mime == TARGETS_MIME:
                payload = ' '.join(cp.get_available_mime_types_for_paste()).encode('utf-8')
                if payload:
                    payload += b'\n'
                w.screen.send_escape_code_to_child(ESC_OSC, rr.encode_response(payload=payload, mime=current_mime))
                continue
            try:
                cp.get_mime(mime, write_chunks)
            except Exception as e:
                log_error(f'Failed to read requested mime type {mime} with error: {e}')
        w.screen.send_escape_code_to_child(ESC_OSC, rr.encode_response(status='DONE'))

    def reject_read_request(self, rr: ReadRequest) -> None:
        if rr.protocol_type is ProtocolType.osc_52:
            return self.fulfill_legacy_read_request(rr, False)
        w = get_boss().window_id_map.get(self.window_id)
        if w is not None:
            w.screen.send_escape_code_to_child(ESC_OSC, rr.encode_response(status='EPERM'))

    def fulfill_legacy_read_request(self, rr: ReadRequest, allowed: bool = True) -> None:
        cp = get_boss().primary_selection if rr.is_primary_selection else get_boss().clipboard
        w = get_boss().window_id_map.get(self.window_id)
        if w is not None:
            text = ''
            if cp.enabled and allowed:
                text = cp.get_text()
            loc = 'p' if rr.is_primary_selection else 'c'
            w.screen.send_escape_code_to_child(ESC_OSC, encode_osc52(loc, text))

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Only request MIME types you know may be present (or handle empty responses gracefully)
  2. Retry the read once — clipboard owner races are transient
  3. Update kitty; provider-specific bugs get patched
Defensive patterns

Strategy: retry

Validate before calling

null  # cannot validate OS clipboard contents reliably beforehand

Try / catch

try:\n    cp.get_mime(mime, write_chunks)\nexcept Exception:\n    continue  # skip this MIME type, response still ends DONE

Prevention

When it happens

Trigger: A read request asking for a MIME type the OS clipboard has no data for, or the OS clipboard API raising during retrieval (e.g. Wayland/X11 clipboard manager hiccup, image MIME missing).

Common situations: Clients requesting image/png when only text is present on servers that error instead of returning empty; races where the clipboard owner disappears mid-read.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/83f3d17da9b2890c. Report an issue: GitHub.