Open jemag opened 1 year ago
Seems like there is a non UTF-8 character in my history hence why it errors out.
Even if there is no sanitizing, it would probably be best to handle the error.
For now, I can probably work around with a fork and something like:
local ok
ok, params.body = pcall(vim.fn.json_encode, params.body)
if not ok then
return
end
is there any issue preventing using a proper pcall with vim.fn.json_encode
?
I would much rather have this change in upstream instead of me having to maintain a fork with the following changes to the post
function:
local ok, encoded_body = pcall(vim.fn.json_encode, params.body)
if not ok then
log.error('Could not json_encode body')
f:close()
return
end
f:write(encoded_body)
I would submit a PR but I think there's probably a cleaner way to go about this
At first I thought it was related to https://github.com/jcdickinson/codeium.nvim/issues/20, but it doesn't seem like it.
Basically, in my command history I have the following (taken from
main.shada
file):When I am in the command window
q:
, editing something that will trigger completion will make codeium fail with the following:What seems to happen is that the
param.body
contains my history, which in turn contains this<89>
char which will then fail thevim.fn.json_encode
from : https://github.com/jcdickinson/codeium.nvim/blob/55fa67bd316e2a4d312b11d68a2c34f898925a7f/lua/codeium/io.lua#L403-L408Not sure what is the best approach, but I am guessing that
params.body
probably needs to be sanitized before being passed tovim.fn.json_encode
to prevent this kind of errors.