MoonshotAI / MoonshotAI/kimi-cli

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

Open
#1,757 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
11.4k
Forks
1.3k
Avg merge
9h 47m
Merged PRs (30d)
2

Description

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 #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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Ctrl+V handler and _try_paste_media(), then inspect prompt_toolkit's PyperclipClipboard.get_data() and the pyperclip.paste() result. Reproduce with an image and other non-text clipboard contents; done means the unsupported-image warning remains without a crash and empty text paste is ignored.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.