fwcd / fwcd/kotlin-language-server

Kotlin Language Server Crashes on Neovim Due to JSON Parsing Error (Expected BEGIN_OBJECT but was BEGIN_ARRAY)

Open
#648 5 comments 18 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
2k
Forks
252
PR merge metrics
No merged PRs in 30d

Description

I'm encountering a crash when using `kotlin-language-server` with Neovim. The error suggests a `JsonSyntaxException`, where the server expects a `BEGIN_OBJECT` but encounters a `BEGIN_ARRAY`.

#### **Environment:**
- **Neovim version:**
NVIM v0.10.4
Build type: RelWithDebInfo
LuaJIT 2.1.1736781742
Run "nvim -V1 -v" for more info
- **Operating System:** Arch Linux

#### **Steps to Reproduce:**
1. Start Neovim with `kotlin-language-server` configured.
2. Open a Kotlin file.
3. The server crashes with the following error.

#### **Error Log:**
```
 Error 12:20:10 AM msg_show.lua_error Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/client.lua:588: RPC[Error] code_name = InternalError, message = "Internal error." data = "java.util.concurrent.CompletionException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)\n\tat java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.base/java.lang.Thread.run(Thread.java:840)\nCaused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $\n\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:397)\n\tat com.google.gson.Gson.fromJson(Gson.java:1227)\n\tat com.google.gson.Gson.fromJson(Gson.java:1329)\n\tat com.google.gson.Gson.fromJson(Gson.java:1271)\n\tat org.javacs.kt.ConfigurationKt.getStoragePath(Configuration.kt:81)\n\tat org.javacs.kt.KotlinLanguageServer.initialize$lambda$6(KotlinLanguageServer.kt:97)\n\tat org.javacs.kt.util.AsyncExecutor.compute$lambda$2(AsyncExecutor.kt:19)\n\tat java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)\n\t... 3 more\nCaused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $\n\tat com.google.gson.internal.bind.JsonTreeReader.expect(JsonTreeReader.java:165)\n\tat com.google.gson.internal.bind.JsonTreeReader.beginObject(JsonTreeReader.java:89)\n\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:386)\n\t... 10 more\n"
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the crash from Neovim while opening a Kotlin file, then inspect org.javacs.kt.ConfigurationKt.getStoragePath at Configuration.kt:81 and KotlinLanguageServer.initialize at KotlinLanguageServer.kt:97. Determine which initialization input is parsed as an array instead of an object; done means the reported setup no longer crashes and the initialization path handles the received JSON shape correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin, neovim
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.