Skip to content

Ctrl+V crashes with TypeError when clipboard contains non-text data (e.g. screenshot) #1757

@exqqstar

Description

@exqqstar

What version of Kimi Code CLI is running?

kimi, version 1.30.0

Which open platform/subscription were you using?

N/A (reproducible on any platform)

Which model were you using?

No response

What platform is your computer?

Darwin 25.2.0 arm64 arm

What issue are you seeing?

Pressing Ctrl+V crashes with a TypeError when the system clipboard holds non-text data (e.g. a screenshot). The
traceback points to prompt_toolkit internals doing "\n" in text where text is None because pyperclip.paste()
returned None.
Two distinct trigger paths lead to this crash:

  1. Screenshot in clipboard + model doesn't support image input: _try_paste_media() detects the image, prints a
    warning, but returns False. The Ctrl+V handler then falls through to the text paste path, where pyperclip.paste()
    returns None → TypeError.
  2. Any non-text clipboard content (covered by Crash when clipboard is empty during Ctrl-V paste #1750): pyperclip.paste() returns None regardless of whether
    media detection ran, and prompt_toolkit's PyperclipClipboard.get_data() crashes on it.
    TypeError: argument of type 'NoneType' is not iterable

What steps can reproduce the bug?

  1. Start kimi-cli with a model that does not support image input
  2. Take a screenshot (so the clipboard holds an image)
  3. Press Ctrl+V in the prompt

What is the expected behavior?

  • If the model doesn't support images: show the "Image input is not supported" warning and do nothing else (no crash)
  • If the clipboard simply has no text: silently ignore the paste (no crash)

Additional information

Related to #1750.
A fix is available at exqqstar/kimi-cli@e2230992
(branch:
fix/clipboard-crash-non-text-paste).
Will open a PR once this issue is confirmed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions