@@ -44,6 +44,23 @@ def test_project_user_config_workspace_table_raises(tmp_path: pathlib.Path) -> N
4444 read_project_user_config (tmp_path )
4545
4646
47+ def test_project_user_config_tool_table_raises (tmp_path : pathlib .Path ) -> None :
48+ """A [tool] table in finecode-user.toml is rejected with a clear error.
49+
50+ finecode-user.toml is unwrapped (no [tool.finecode] prefix); writing
51+ [tool.finecode.action.x] instead of [action.x] used to reach
52+ `_merge_projects_configs` and crash there with a bare `KeyError('tool')`
53+ surfaced to the client as `API error (-32603): 'tool'`. Reject it eagerly
54+ with an actionable message instead.
55+ """
56+ _write_toml (
57+ tmp_path / "finecode-user.toml" ,
58+ "[tool.finecode.action.lint]\n handlers = []\n " ,
59+ )
60+ with pytest .raises (config_models .ConfigurationError , match = r"\[tool\]" ):
61+ read_project_user_config (tmp_path )
62+
63+
4764def test_project_user_config_malformed_raises (tmp_path : pathlib .Path ) -> None :
4865 """A parse error in finecode-user.toml is a hard failure.
4966
@@ -846,3 +863,20 @@ def test_preset_user_config_workspace_table_raises(tmp_path: pathlib.Path) -> No
846863 _write_toml (tmp_path / "finecode-user.toml" , "[workspace]\n foo = 1\n " )
847864 with pytest .raises (config_models .ConfigurationError , match = "workspace" ):
848865 read_preset_config (tmp_path / "preset.toml" , "mypkg" )
866+
867+
868+ def test_preset_user_config_tool_table_raises (tmp_path : pathlib .Path ) -> None :
869+ """A [tool] table in a preset-level finecode-user.toml is rejected.
870+
871+ Same double-wrapping bug as at the project level — a preset's
872+ finecode-user.toml is unwrapped, so [tool.finecode.action.x] used to
873+ reach `_merge_projects_configs` and crash with a bare `KeyError('tool')`
874+ instead of an actionable error.
875+ """
876+ _write_minimal_preset (tmp_path )
877+ _write_toml (
878+ tmp_path / "finecode-user.toml" ,
879+ "[tool.finecode.action.lint]\n handlers = []\n " ,
880+ )
881+ with pytest .raises (config_models .ConfigurationError , match = r"\[tool\]" ):
882+ read_preset_config (tmp_path / "preset.toml" , "mypkg" )
0 commit comments