Skip to content

[BUG] LSP hover crashes with 'undefined is not an Object' when hover returns null result #4

@FBakkensen

Description

@FBakkensen

Description

When the AL LSP returns a null/empty result for a hover request (which is valid LSP behavior when there's nothing to hover on), Claude Code crashes with:

Error performing hover: undefined is not an Object. (evaluating '"kind"in H')

Reproduction Steps

  1. Install AL LSP plugin (al-language-server-go-windows v1.3.12)
  2. Open any AL file (e.g., a Table or Codeunit)
  3. Call hover on a position with content (e.g., table name, variable, or type) → Works correctly
  4. Call hover on a position without content (empty line, whitespace, or position with no hover info) → Crashes

Environment

  • OS: Windows
  • Claude Code Version: Latest (2.x)
  • AL LSP Plugin Version: 1.3.12

Root Cause Analysis

The Go wrapper logs show successful request/response flow:

Received from client: method=textDocument/hover
Sending request to AL LSP: method=textDocument/hover
Received response from AL LSP
Sending response to client

The wrapper is correctly forwarding the response. The crash happens in Claude Code's JavaScript code when it tries to check "kind" in H where H (the hover contents) is undefined/null.

Suggested Fix

The wrapper could potentially work around this by:

  1. Checking if the AL LSP returns null/empty for hover
  2. Returning a valid but empty MarkupContent structure, e.g.:
    {"contents": {"kind": "plaintext", "value": ""}}

This would prevent Claude Code from crashing while the upstream bug in Claude Code is addressed.

Related

This is ultimately a bug in Claude Code's LSP handler (not handling null hover responses), but a workaround in the wrapper would help AL LSP users immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions