jackMort / jackMort/ChatGPT.nvim
crash on function_call null
- Dominant language
- Lua
- Stars
- 4k
- Forks
- 317
- PR merge metrics
- No merged PRs in 30d
Description
Here is the response from my openAI API :
```
{
"id":"chatcmpl-c3113b31-5c09-4b50-a891-14a460fb6c0d",
"created":1739033926,
"model":"claude-3-5-sonnet-v2",
"object":"chat.completion",
"system_fingerprint":null,
"choices":[
{
"finish_ reason":"stop",
"index":0,
"message":{
"content":"Here's a simple code with three lines of ""hello world"" variations:\n\n\nHello, World!\nGreetings, Universe!\nHi there, Everyone !\n",
"role":"assistant",
"tool_calls":null,
"function_call":null
}
}
],
"usage":{
"completion_tokens":41,
"prompt_tokens":19,
"total_tokens":60,
"completion_tokens_details":null,
"prompt_ tokens_details":{
"audio_tokens":null,
"cached_tokens":0
},
"cache_creation_input_tokens":0,
"cache_read_input_tokens":0
}
}
```
Note that `"function_call":null`
This will lead to following crash :
Press ENTER or type command to continue Error executing vim.schedule lua callback: .../.local/share/nvim/lazy/ChatGPT.nvim/lua/chatgpt/api.lua:170: attempt to index field 'function_call' (a userdata value) stack traceback: .../.local/share/nvim/lazy/ChatGPT.nvim/lua/chatgpt/api.lua:170: in function '' vim/_editor.lua: in function
suggestion is to replace in file : ChatGPT.nvim/lua/chatgpt/api.lua
```lua
if first_message.function_call
message_response = vim.fn.json_decode(first_message.function_call.arguments)
else
```
by
```lua
if first_message.function_call and first_message.function_call ~= vim.NIL then
message_response = vim.fn.json_decode(first_message.function_call.arguments)
else
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at lua/chatgpt/api.lua around line 170, where the response handler indexes first_message.function_call, and inspect how a null value is represented by Neovim's JSON decoder. Verify the handler accepts the shown response with function_call set to null without crashing and still processes the message content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, neovim
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100