Skip to content

Commit f886bad

Browse files
authored
core : check FIM response for expected format (#73)
1 parent 3c1248c commit f886bad

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

autoload/llama.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,16 @@ function! s:fim_on_response(hashes, job_id, data, event = v:null)
685685
return
686686
endif
687687

688+
" ensure the response is valid JSON, starting with a fast check before full decode
689+
if l:raw !~# '^\s*{' || l:raw !~# '\v"content"\s*:"'
690+
return
691+
endif
692+
try
693+
let l:response = json_decode(l:raw)
694+
catch
695+
return
696+
endtry
697+
688698
" put the response in the cache
689699
for l:hash in a:hashes
690700
call s:cache_insert(l:hash, l:raw)

0 commit comments

Comments
 (0)