MoonshotAI / MoonshotAI/kimi-cli
Crash when clipboard is empty during Ctrl-V paste
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Bug Description
Unhandled exception occurs when pressing Ctrl-V with an empty clipboard.
Steps to Reproduce
- Clear clipboard (or have empty clipboard)
- Press Ctrl-V in kimi CLI input box
Environment
- macOS
- Kimi Code CLI version: (run
/versionto get) - Terminal: ghostty
Error Traceback
Exception argument of type 'NoneType' is not iterable
File "/opt/homebrew/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/events.py", line 89, in _run
self._context.run(self._callback, *self._args)
File ".../prompt_toolkit/application/application.py", line 714, in read_from_input_in_context context.copy().run(read_from_input)
File ".../prompt_toolkit/clipboard/pyperclip.py", line 41, in _ type=SelectionType.LINES if "\n" in text else SelectionType.CHARACTERS, ^^^
^^^^^^^^^
Root Cause
In prompt_toolkit/clipboard/pyperclip.py line 41, the code checks "\n" in text without first verifying that text is not None. When
clipboard is empty, text is None, causing TypeError: argument of type 'NoneType' is not iterable.
Suggested Fix
Add a null check before the in operator:
type=SelectionType.LINES if text and "\n" in text else SelectionType.CHARACTERS,
---
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in prompt_toolkit/clipboard/pyperclip.py at the line shown in the traceback, then reproduce the crash with an empty clipboard while pressing Ctrl-V in the Kimi CLI input box. Verify that empty clipboard pastes no longer raise the reported NoneType exception, while normal clipboard content continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100