oraios/serena · error · ValueError

Invalid ls_specific_settings.java.runtimes entry {entry!r}:

Error message

Invalid ls_specific_settings.java.runtimes entry {entry!r}: each entry requires at least a 'name' and a 'path' key.

What it means

ValueError raised by _resolve_configured_runtimes when an entry in ls_specific_settings.java.runtimes is not a dict or lacks the required 'name' and/or 'path' keys. Each entry must identify a named JDK (e.g. JavaSE-21) and its installation path so it can be normalized into JDT-LS's javaRuntimes format.

Source

Thrown at src/solidlsp/language_servers/eclipse_jdtls.py:876

        sends via ``java.configuration.runtimes`` (``name``, ``path``, optional ``default``/``sources``/
        ``javadoc``); see serena #1478.

        :return: the validated list of runtime dicts (empty if the setting is unset)
        :raises ValueError: if the setting or one of its entries is malformed
        :raises FileNotFoundError: if an entry's ``path`` does not exist
        """
        configured_runtimes = self._custom_settings.get("runtimes", [])
        if not isinstance(configured_runtimes, list):
            raise ValueError(
                f"ls_specific_settings.java.runtimes must be a list of {{name, path}} entries, "
                f"got {type(configured_runtimes).__name__}: {configured_runtimes!r}"
            )

        # validate each entry and normalize it to the shape JDT-LS expects...
        validated_runtimes: list[dict[str, Any]] = []
        for entry in configured_runtimes:
            if not isinstance(entry, dict) or "name" not in entry or "path" not in entry:
                raise ValueError(
                    f"Invalid ls_specific_settings.java.runtimes entry {entry!r}: each entry requires at least a 'name' and a 'path' key."
                )
            path = entry["path"]
            if not os.path.exists(path):
                error_msg = (
                    f"ls_specific_settings.java.runtimes entry '{entry['name']}' points to a path that "
                    f"does not exist: {path}. Fix: update the path in ~/.serena/serena_config.yml "
                    f"(ls_specific_settings -> java -> runtimes), or remove the entry."
                )
                log.error(error_msg)
                raise FileNotFoundError(error_msg)

            runtime: dict[str, Any] = {"name": entry["name"], "path": path}
            if "default" in entry:
                runtime["default"] = bool(entry["default"])
            for optional_key in ("sources", "javadoc"):
                if optional_key in entry:
                    runtime[optional_key] = entry[optional_key]

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Give each entry both 'name' and 'path' keys, e.g. {name: JavaSE-21, path: /usr/lib/jvm/temurin-21}
  2. Convert bare string paths into dict entries
  3. Fix typo'd key names so 'name' and 'path' exist exactly
  4. Ensure the 'path' points to an existing JDK home (a follow-up FileNotFoundError otherwise)

Example fix

# before
runtimes:
  - /usr/lib/jvm/temurin-21
# after
runtimes:
  - name: JavaSE-21
    path: /usr/lib/jvm/temurin-21
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
def validate_runtime_entries(runtimes: list) -> bool:
    return all(
        isinstance(r, dict) and "name" in r and "path" in r and Path(r["path"]).exists()
        for r in runtimes
    )

Type guard

def is_valid_runtime_entry(e: object) -> bool:
    return (
        isinstance(e, dict)
        and isinstance(e.get("name"), str)
        and isinstance(e.get("path"), str)
        and Path(e["path"]).exists()
    )

Try / catch

try:
    params = provider._create_base_initialize_params()
except ValueError as e:
    if "requires at least a 'name' and a 'path' key" in str(e):
        cfg["ls_specific_settings"]["java"]["runtimes"] = fix_entries(cfg["ls_specific_settings"]["java"]["runtimes"])
        params = provider._create_base_initialize_params()
    else:
        raise

Prevention

When it happens

Trigger: _create_base_initialize_params -> _resolve_configured_runtimes iterating the runtimes list: an entry fails 'isinstance(entry, dict) and "name" in entry and "path" in entry', e.g. a bare string path, or a dict missing 'path'.

Common situations: List of plain path strings instead of dicts; typo'd key ('paht', 'jdk_name'); entry with only 'name' and the path given as a sibling key; copy-paste leaving an entry half-filled.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/8ac8c1ac3b3842c9. Report an issue: GitHub.