From 413fd5ad0c20a626be9aef92b15a66e39f22bfa4 Mon Sep 17 00:00:00 2001 From: Chris Nestrud Date: Sun, 4 Jan 2026 07:37:13 -0600 Subject: [PATCH] fix: handle None command_paths without warning --- cecli/commands/core.py | 17 ++++++++++++----- tests/basic/test_commands.py | 11 +++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cecli/commands/core.py b/cecli/commands/core.py index dec20df51c1..fc512f47f8b 100644 --- a/cecli/commands/core.py +++ b/cecli/commands/core.py @@ -80,11 +80,18 @@ def __init__( self.editor = editor self.original_read_only_fnames = set(original_read_only_fnames or []) - try: - self.custom_commands = json.loads(getattr(self.args, "command_paths", "[]")) - except (json.JSONDecodeError, TypeError) as e: - self.io.tool_warning(f"Failed to parse command paths JSON: {e}") - self.custom_commands = [] + command_paths_raw = getattr(self.args, "command_paths", None) + if isinstance(command_paths_raw, (list, tuple)): + # When the parser already produced a list/tuple, accept it directly + self.custom_commands = list(command_paths_raw) + else: + if command_paths_raw is None: + command_paths_raw = "[]" + try: + self.custom_commands = json.loads(command_paths_raw) + except (json.JSONDecodeError, TypeError) as e: + self.io.tool_warning(f"Failed to parse command paths JSON: {e}") + self.custom_commands = [] # Load custom commands from plugin paths self._load_custom_commands(self.custom_commands) diff --git a/tests/basic/test_commands.py b/tests/basic/test_commands.py index a508dea2f4f..c961e7f6ce6 100644 --- a/tests/basic/test_commands.py +++ b/tests/basic/test_commands.py @@ -6,6 +6,7 @@ import tempfile from io import StringIO from pathlib import Path +from types import SimpleNamespace from unittest import TestCase, mock import git @@ -130,6 +131,16 @@ async def test_cmd_copy_with_cur_messages(self): # Assert tool_error was called indicating no assistant messages mock_tool_error.assert_called_once_with("No assistant messages found to copy.") + def test_command_paths_none_does_not_warn(self): + io = InputOutput(pretty=False, fancy_input=False, yes=True) + args = SimpleNamespace(command_paths=None) + + with mock.patch.object(io, "tool_warning") as tool_warning: + commands = Commands(io, coder=None, args=args) + + self.assertEqual(commands.custom_commands, []) + tool_warning.assert_not_called() + async def test_cmd_copy_pyperclip_exception(self): io = InputOutput(pretty=False, fancy_input=False, yes=True) coder = await Coder.create(self.GPT35, None, io)