Fix: get_diagnostics_for_file crashed with SolidLSPException for any Ansible file with at least one finding

`ansible-language-server` doesn't implement `textDocument/documentSymbol`
and the request used to map diagnostics onto owning symbols just threw. `AnsibleLanguageServer` now
overrides that request to return `None` directly, so diagnostics fall back to being grouped under
the file-level path #1758

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Kyle HutchinsonandClaude Sonnet 5 authored and GitHub committed 2026-07-29 01:47:27 +02:00
1 parent 6c1c965370
commit 32308a871c
3 files changed
+26 -1

No files matched your search

+5
View File
@@ -19,6 +19,11 @@ Status of the `main` branch. Changes prior to the next official version change w
project creation)
- Add `python_basedpyright` as an alternative Python language server
- Nix/nixd: support custom `ls_path` launchers and external JSON settings through `config_path` #1737
- Fix: `get_diagnostics_for_file` crashed with `SolidLSPException` for any Ansible file with at least
one lint finding, because `ansible-language-server` doesn't implement `textDocument/documentSymbol`
and the request used to map diagnostics onto owning symbols just threw. `AnsibleLanguageServer` now
overrides that request to return `None` directly, so diagnostics fall back to being grouped under
the file-level path as already documented #1758
* JetBrains:
- `jet_brains_find_symbol`: Disallow wildcard-only search, delegating to overview tool if request is for file
@@ -12,8 +12,9 @@ from typing import Any, ClassVar
from overrides import override
from solidlsp.language_servers.common import RuntimeDependency, RuntimeDependencyCollection, build_npm_install_command
from solidlsp.ls import LanguageServerDependencyProvider, LanguageServerDependencyProviderSinglePath, SolidLanguageServer
from solidlsp.ls import LanguageServerDependencyProvider, LanguageServerDependencyProviderSinglePath, LSPFileBuffer, SolidLanguageServer
from solidlsp.ls_config import LanguageServerConfig
from solidlsp.lsp_protocol_handler.lsp_types import DocumentSymbol, SymbolInformation
from solidlsp.settings import SolidLSPSettings
log = logging.getLogger(__name__)
@@ -125,6 +126,15 @@ class AnsibleLanguageServer(SolidLanguageServer):
return False
@override
def _request_document_symbols(
self, relative_file_path: str, file_data: LSPFileBuffer | None
) -> list[SymbolInformation] | list[DocumentSymbol] | None:
# ansible-language-server does not implement textDocument/documentSymbol and the
# maintainers have declined to add it (see ansible/vscode-ansible#601, closed NOT_PLANNED).
# Skip the request entirely rather than sending a request we know will fail.
return None
@staticmethod
def _determine_log_level(line: str) -> int:
"""Classify ansible-language-server stderr output to avoid false-positive errors."""
@@ -11,11 +11,21 @@ from pathlib import Path
import pytest
from solidlsp import SolidLanguageServer
from solidlsp.language_servers.ansible_language_server import AnsibleLanguageServer
from solidlsp.ls_config import LanguageServerId
from test.conftest import language_server_tests_enabled
from test.solidlsp.conftest import format_symbol_for_assert, has_malformed_name, request_all_symbols
def test_request_document_symbols_returns_none_without_contacting_server() -> None:
"""ansible-language-server has no textDocument/documentSymbol support (see
ansible/vscode-ansible#601, closed NOT_PLANNED), so the override must short-circuit
to None instead of sending a request that is guaranteed to fail. Runs with no
language server process, node, or npm required.
"""
assert AnsibleLanguageServer._request_document_symbols(None, "playbook.yml", None) is None
@pytest.mark.skipif(
not language_server_tests_enabled(LanguageServerId.ANSIBLE), reason="Ansible tests are disabled (no native Windows support)"
)