oraios/serena · error · SolidLSPException

Language Server not started

Error message

Language Server not started

What it means

request_text_document_diagnostics and its cached/published variants call _validate_text_document_diagnostics_request first. If the underlying language server process has not been started yet (self.server_started is False), a SolidLSPException('Language Server not started') is raised, because there is no server to publish or query diagnostics from.

Source

Thrown at src/solidlsp/ls.py:816

        diagnostics: list[ls_types.Diagnostic],
        start_line: int,
        end_line: int,
        min_severity: int,
    ) -> list[ls_types.Diagnostic]:
        diagnostics = [d for d in diagnostics if cls._diagnostic_matches_range(d, start_line, end_line)]
        diagnostics = [d for d in diagnostics if cls._diagnostic_matches_min_severity(d, min_severity)]
        return diagnostics

    def _validate_text_document_diagnostics_request(
        self,
        relative_file_path: str,
        start_line: int,
        end_line: int,
        min_severity: int,
    ) -> str:
        if not self.server_started:
            log.error("request_text_document_diagnostics called before Language Server started")
            raise SolidLSPException("Language Server not started")
        if start_line < 0:
            raise ValueError(f"start_line must be non-negative, got {start_line}")
        if end_line != -1 and end_line < start_line:
            raise ValueError(f"end_line must be -1 or >= start_line, got {end_line} < {start_line}")
        if min_severity not in {1, 2, 3, 4}:
            raise ValueError(f"min_severity must be one of 1, 2, 3, 4, got {min_severity}")
        return pathlib.Path(str(PurePath(self.repository_root_path, relative_file_path))).as_uri()

    def get_published_diagnostics_generation(self, relative_file_path: str) -> int:
        """
        Get the generation number for the latest published diagnostics of a file.

        :param relative_file_path: The relative path of the file.
        :return: the generation number, or ``-1`` if none were published yet.
        """
        uri = pathlib.Path(str(PurePath(self.repository_root_path, relative_file_path))).as_uri()
        return self._get_published_diagnostics_generation(uri)

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Call and await language_server.start() before requesting diagnostics
  2. Check the server_started flag or gate queries behind a start-completed event
  3. Investigate server startup logs if start() was called but the flag is still False (server may have crashed)

Example fix

// before
ls = SolidLSP(repo_root)
diags = ls.request_text_document_diagnostics("src/a.py", 0, -1, 3)
// after
ls = SolidLSP(repo_root)
ls.start()
diags = ls.request_text_document_diagnostics("src/a.py", 0, -1, 3)
Defensive patterns

Strategy: try-catch

Validate before calling

if not ls.server_started:
    ls.start()

Try / catch

try:
    diags = ls.request_text_document_diagnostics(rel_path, 0, -1, 3)
except SolidLSPException as e:
    if "not started" in str(e):
        ls.start()
        diags = ls.request_text_document_diagnostics(rel_path, 0, -1, 3)
    else:
        raise

Prevention

When it happens

Trigger: Calling request_text_document_diagnostics, request_published_text_document_diagnostics, or get_cached_published_text_document_diagnostics before start()/initialization of the SolidLSP instance completes (or after the server failed to start).

Common situations: Calling diagnostics from another thread/async task before await start(); constructing the language server and immediately querying; the LS crashed on startup so server_started never became True.

Related errors


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