oraios/serena · error · ValueError
ls_specific_settings.typescript_vts.initialization_options m
Error message
ls_specific_settings.typescript_vts.initialization_options must be a dict, got {type(opts).__name__} What it means
Thrown as ValueError when user-supplied configuration ls_specific_settings.typescript_vts.initialization_options is not None but is also not a dict. The VTS language server can only merge dict-shaped initialization options into its initialize params.
Source
Thrown at src/solidlsp/language_servers/vts_language_server.py:137
vts_executable_path = os.path.join(vts_ls_dir, "node_modules", ".bin", "vtsls")
assert os.path.exists(vts_executable_path), "vtsls executable not found. Please install @vtsls/language-server and try again."
return f"{vts_executable_path} --stdio"
@property
def _initialization_options(self) -> dict:
"""
Validated user-provided ``initializationOptions``.
:raises ValueError: if ``ls_specific_settings.typescript_vts.initialization_options``
is set to a value that is not a dict.
"""
opts = self._custom_settings.get("initialization_options")
if opts is None:
return {}
if not isinstance(opts, dict):
raise ValueError(f"ls_specific_settings.typescript_vts.initialization_options must be a dict, got {type(opts).__name__}")
return opts
def _create_base_initialize_params(self) -> dict:
"""
Returns the initialize params for the VTS Language Server.
If ``initialization_options`` is set in ``ls_specific_settings["typescript_vts"]``,
it is forwarded verbatim as LSP ``initializationOptions``.
"""
initialize_params: dict = {
"locale": "en",
"initializationOptions": {
"preferences": {
"disableAutomaticTypingAcquisition": True,
},
},
"capabilities": {
"textDocument": {View on GitHub (pinned to 7fcbca7e62)
Solutions
- Change initialization_options in ls_specific_settings.typescript_vts to a proper mapping/dict.
- Unquote stringified JSON objects (e.g. "{'preferStubs': true}" → {'preferStubs': true}).
- If no options are needed, remove the key entirely rather than setting it to a non-dict; None/absent returns {}.
- Validate the config schema before constructing the language server.
Example fix
// before
settings = {"ls_specific_settings": {"typescript_vts": {"initialization_options": "preferStubs=true"}}}
// after
settings = {"ls_specific_settings": {"typescript_vts": {"initialization_options": {"preferStubs": True}}}} Defensive patterns
Strategy: validation
Validate before calling
opts = settings.get("ls_specific_settings", {}).get("typescript_vts", {}).get("initialization_options")
if opts is not None and not isinstance(opts, dict):
raise TypeError("typescript_vts.initialization_options must be a dict") Type guard
def is_init_options(value: object) -> bool:
return value is None or isinstance(value, dict) Try / catch
try:
ls = SolidLSP("vts", repo_path, settings)
except ValueError as e:
if "initialization_options must be a dict" in str(e):
settings["ls_specific_settings"]["typescript_vts"]["initialization_options"] = {}
ls = SolidLSP("vts", repo_path, settings)
else:
raise Prevention
- Validate config against a schema (pydantic/jsonschema) at load time.
- Beware YAML/TOML indentation making nested objects into strings.
- Omit initialization_options entirely when not needed instead of passing a scalar.
- Add a unit test that loads your production config through the server constructor.
When it happens
Trigger: Passing config where initialization_options under typescript_vts is a string, list, number, or bool; _initialization_options reads self._custom_settings["initialization_options"] and raises on the type mismatch.
Common situations: YAML/JSON config where options were written as a quoted string; hand-editing config and dropping the braces around a nested object; copying TOML/YAML settings with wrong indentation so the value becomes a scalar.
Related errors
- Unknown language '{lang}'. Supported: {all_langs}
- Cannot use both fixed_tools and excluded_tools/included_opti
- Unknown language backend '{backend_str}': valid values are {
- Invalid line_ending: {value!r}. Valid values are: {valid}
- Invalid language server: '{orig_language_str}'.\nValid value
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/9d7b6d772cb84519.
Report an issue: GitHub.