oraios/serena · error · ValueError

Invalid language server identifier: {request_add_language.la

Error message

Invalid language server identifier: {request_add_language.language}

What it means

The add-language endpoint converts the requested language string to a `LanguageServerId` enum (solidlsp.ls_config). If the string doesn't match any enum member, LanguageServerId raises ValueError, which `_add_language` re-raises as ValueError('Invalid language server identifier: ...'). Only exact, case-matching language identifiers accepted by solidlsp are valid.

Source

Thrown at src/serena/dashboard.py:783

    def _load_previously_fetched_news_data() -> dict[str, str]:
        """Return the news data dict. Uses local cache if available, otherwise falls back to local news files."""
        paths = SerenaPaths()

        if os.path.exists(paths.news_file):
            try:
                with open(paths.news_file, encoding="utf-8") as f:
                    return json.loads(f.read())
            except Exception:
                log.warning("Failed to read cached news data from %s", paths.news_file)
        return {}

    def _add_language(self, request_add_language: RequestAddLanguage) -> None:
        from solidlsp.ls_config import LanguageServerId

        try:
            language = LanguageServerId(request_add_language.language)
        except ValueError:
            raise ValueError(f"Invalid language server identifier: {request_add_language.language}")
        # add_language is already thread-safe
        self._agent.add_language_server(language)

    def _remove_language(self, request_remove_language: RequestRemoveLanguage) -> None:
        from solidlsp.ls_config import LanguageServerId

        try:
            language = LanguageServerId(request_remove_language.language)
        except ValueError:
            raise ValueError(f"Invalid language server identifier: {request_remove_language.language}")
        # remove_language is already thread-safe
        self._agent.remove_language_server(language)

    @staticmethod
    def _find_first_free_port(start_port: int, host: str) -> int:
        port = start_port
        while port <= 65535:
            try:

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Use an exact identifier from the LanguageServerId enum in solidlsp/ls_config.py (e.g. print the enum members) for the request body.
  2. Fix casing/typo in the `language` field — enum lookup is case-sensitive.
  3. Upgrade solidlsp/Serena if the language exists only in newer releases.
  4. Wrap the call in try/except ValueError and surface the list of valid identifiers to the user.

Example fix

// before
await fetch(`${dashboard}/add_language`, {method: "POST", body: JSON.stringify({language: "ts"})});
// after
await fetch(`${dashboard}/add_language`, {method: "POST", body: JSON.stringify({language: "typescript"})});
Defensive patterns

Strategy: validation

Validate before calling

from solidlsp.ls_config import LanguageServerId
if request_language not in {m.value for m in LanguageServerId}:
    raise ValueError(f"{request_language} not supported; valid: {sorted(m.value for m in LanguageServerId)}")

Type guard

def is_valid_language(name: str) -> bool:
    try:
        LanguageServerId(name)
        return True
    except ValueError:
        return False

Try / catch

try:
    requests.post(f"{dashboard}/add_language", json={"language": lang})
except ValueError as e:
    logger.error("Bad language id %r; valid ids: %s", lang, [m.value for m in LanguageServerId])

Prevention

When it happens

Trigger: Calling the dashboard /add_language endpoint with `language` values such as 'typescript' (when the enum expects 'typescriptreact' or a different casing), 'python3', 'c++', or any misspelled/unsupported identifier.

Common situations: Hard-coding a language name not in the supported LanguageServerId enum; casing mismatches; using a language added in a newer solidlsp version than the installed one; typos in dashboard automation scripts.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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