Skip to content

Conversation

@agity7
Copy link

@agity7 agity7 commented Jul 3, 2025

Summary

This PR wraps vim.fn.json_encode() in a pcall() to avoid crashing when Codeium tries to encode invalid UTF-8 payloads.

Problem

Some buffers (e.g., minified .mjs, .sum, or binary-like files) contain invalid UTF-8. Codeium tries to encode the completion request payload with vim.fn.json_encode, leading to:

Vim:E474: String contains byte that does not start any UTF-8 character

Fix

  • Wraps the encoding with pcall.
  • Logs a meaningful error and returns early if encoding fails.

Tested locally with such files, and Codeium no longer crashes.

Fixes a class of bugs seen when using preview panels or telescope buffers as well.

…nt crash on invalid UTF-8 when encoding request body
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Philippe seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants