mpfaffenberger / mpfaffenberger/code_puppy
ModelNameCompleter crashes with AttributeError when no model is configured (get_active_model() returns None)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 814
- Forks
- 278
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 76
Description
Problem
ModelNameCompleter.get_completions() in code_puppy/command_line/model_picker_completion.py:73-118 crashes the prompt completion when no model is configured:
active_model_name = get_active_model() # line 104 — can return None
if model_name.lower() == active_model_name.lower(): # AttributeError on None
get_active_model() delegates to get_global_model_name() (config.py:604), whose docstring explicitly states it returns None if unset (fresh install before /add_model, or an invalid configured model with an empty merged config). The first time the user types /model to fix that situation, the completer raises AttributeError: 'NoneType' object has no attribute 'lower' inside prompt_toolkit's completion thread.
Two adjacent smells in the same method:
active_model_name = get_active_model()is re-evaluated inside the per-model loop (once per model in the catalog) even though it cannot change during one completion pass — hoist it above thefor.self.model_names = load_model_names()is captured once in__init__(line 70), so models added via/add_modelmid-session never appear in completions until restart, while the description lookup is live via_load_models_config()— inconsistent freshness.
Suggested fix
active_model_name = (get_active_model() or "").lower()
for model_name in load_model_names(): # or refresh self.model_names per call
...
if model_name.lower() == active_model_name:
Filed by Zen Reviewer C (code-puppy-60635a)
Contributor guide
No contributing guide indexed for this repository
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
Read ModelNameCompleter.get_completions() in code_puppy/command_line/model_picker_completion.py:73-118 and the None behavior documented around get_global_model_name() in config.py:604. Verify /model completion with no configured model and after /add_model; done means completion no longer crashes and newly added models appear without restarting.
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
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100