copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.83k stars 128 forks source link

Error when edit buffer #20

Closed xqliu closed 2 years ago

xqliu commented 2 years ago

Hi,

Suddenly, it shows below errors and stop works

Debugger entered--Lisp error: (wrong-type-argument listp ":0,")
  alist-get(result ":0,")
  (let* ((result (alist-get 'result content)) (err (alist-get 'error content)) (id (alist-get 'id content))) (if err (progn (copilot--log "[ERROR] Error in response: %S\n[ERROR] Response:%S\n" err content))) (if (not id) (if (equal (alist-get 'method content) "LogMessage") (copilot--log "[Agent] %s" (alist-get 'message (alist-get 'params content))) (copilot--log "[INFO] Discard message without id: %S" content)) (funcall (alist-get id copilot--callbacks) (cons (cons 'error err) result)) (assq-delete-all id copilot--callbacks)))
  copilot--process-response(":0,")
  (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))
  (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content)))
  (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))
  (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))
  (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer ...) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn ...) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))
  (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring ... ... full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer ...) full-length) 'utf-8)) (let ((content (condition-case nil ... ...))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))))
  (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string ... ...))) (setq copilot--output-buffer (decode-coding-string (substring ... full-length) 'utf-8)) (let ((content ...)) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))))
  (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content ...)) (setq copilot--output-buffer (decode-coding-string ... ...)) (let (...) (if content ... ...)) (copilot--process-filter process nil)))))))
  (if (and (not header-match) (> (length copilot--output-buffer) 50)) (progn (copilot--log "[Warning] Copilot agent output buffer reset.") (copilot--log "[Warning] Before reset: %S\n" copilot--output-buffer) (setq copilot--output-buffer nil)) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car ...))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let (...) (setq copilot--output-buffer ...) (let ... ...) (copilot--process-filter process nil))))))))
  (let ((header-match (s-match "^Content-Length: \\([0-9]+\\)\15?\n\15?\n" copilot--output-buffer))) (if (and (not header-match) (> (length copilot--output-buffer) 50)) (progn (copilot--log "[Warning] Copilot agent output buffer reset.") (copilot--log "[Warning] Before reset: %S\n" copilot--output-buffer) (setq copilot--output-buffer nil)) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number ...)) (full-length (+ ... content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ... ... ... ...))))))))
  copilot--process-filter(#<process copilot-agent> nil)
  (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))
  (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))
  (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer ...) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn ...) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))
  (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring ... ... full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer ...) full-length) 'utf-8)) (let ((content (condition-case nil ... ...))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))))
  (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string ... ...))) (setq copilot--output-buffer (decode-coding-string (substring ... full-length) 'utf-8)) (let ((content ...)) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))))
  (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content ...)) (setq copilot--output-buffer (decode-coding-string ... ...)) (let (...) (if content ... ...)) (copilot--process-filter process nil)))))))
  (if (and (not header-match) (> (length copilot--output-buffer) 50)) (progn (copilot--log "[Warning] Copilot agent output buffer reset.") (copilot--log "[Warning] Before reset: %S\n" copilot--output-buffer) (setq copilot--output-buffer nil)) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car ...))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let (...) (setq copilot--output-buffer ...) (let ... ...) (copilot--process-filter process nil))))))))
  (let ((header-match (s-match "^Content-Length: \\([0-9]+\\)\15?\n\15?\n" copilot--output-buffer))) (if (and (not header-match) (> (length copilot--output-buffer) 50)) (progn (copilot--log "[Warning] Copilot agent output buffer reset.") (copilot--log "[Warning] Before reset: %S\n" copilot--output-buffer) (setq copilot--output-buffer nil)) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number ...)) (full-length (+ ... content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ... ... ... ...))))))))
  copilot--process-filter(#<process copilot-agent> "[ERROR] [restraint] [2022-05-26T08:22:28.178Z] No ...")

Part of copilot-log buffer

[INFO] Discard message without id: ((jsonrpc . "2.0") (method . "statusNotification") (params (status . "InProgress") (message . "")))
[Agent] [INFO] [default] [2022-05-26T08:22:33.583Z] [fetchCompletions] engine https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex
[INFO] Discard message without id: ((jsonrpc . "2.0") (method . "statusNotification") (params (status . "Normal") (message . "")))
[INFO] Completion: ((error) (completions . []))
[INFO] Completion: ((error) (completions . []))

Seems the format of copilot server return value is not what expected by the program?

If any more information needed, just post here, thanks for the great plugin ;)

zerolfx commented 2 years ago

There are two problems:

  1. Copilot agent reports some error, which shows in the last line of the backtrace. If you encounter this problem again, please expand the line so we can check whether it is expected.
  2. content is a string rather than a list. But content is the result of json-read-from-string, which should return a list. So I don't know what happened there.
SqrtMinusOne commented 2 years ago

I'm also getting similar errors, including one reported above. All of the errors originate from passing non-lists to copilot--process-response.

The details are as follows.

copilot-log ``` [Warning] Copilot agent output buffer reset. [Warning] Before reset: "ssage\":\"\"}}Content-Length: 54 {\"jsonrpc\":\"2.0\",\"id\":490,\"result\":{\"completions\":[]}}Content-Length: 258 {\"jsonrpc\":\"2.0\",\"method\":\"LogMessage\",\"params\":{\"level\":1,\"message\":\"[INFO] [ghostText] [2022-05-29T07:21:03.344Z] Found inline suggestions locally\",\"metadataStr\":\"[INFO] [ghostText] [2022-05-29T07:21:03.344Z]\",\"extra\":[\"Found inline suggestions locally\"]}}Content-Length: 678 {\"jsonrpc\":\"2.0\",\"method\":\"LogMessage\",\"params\":{\"level\":3,\"message\":\"[ERROR] [restraint] [2022-05-29T07:21:03.345Z] No value found for meanLogProb -- only got {\\\"promptCharLen\\\":5168,\\\"promptEndPos\\\":17620,\\\"documentLength\\\":28072,\\\"delayMs\\\":0,\\\"promptComputeTimeMs\\\":8,\\\"timeSinceIssuedMs\\\":1,\\\"numTokens\\\":0,\\\"compCharLen\\\":2,\\\"numLines\\\":1,\\\"python\\\":0}\",\"metadataStr\":\"[ERROR] [restraint] [2022-05-29T07:21:03.345Z]\",\"extra\":[\"No value found for meanLogProb -- only got {\\\"promptCharLen\\\":5168,\\\"promptEndPos\\\":17620,\\\"documentLength\\\":28072,\\\"delayMs\\\":0,\\\"promptComputeTimeMs\\\":8,\\\"timeSinceIssuedMs\\\":1,\\\"numTokens\\\":0,\\\"compCharLen\\\":2,\\\"numLines\\\":1,\\\"python\\\":0}\"]}}Content-Length: 718 {\"jsonrpc\":\"2.0\",\"method\":\"LogMessage\",\"params\":{\"level\":3,\"message\":\"[ERROR] [restraint] [2022-05-29T07:21:03.345Z] No value found for meanLogProb -- only got {\\\"promptCharLen\\\":5168,\\\"promptEndPos\\\":17620,\\\"documentLength\\\":28072,\\\"delayMs\\\":0,\\\"promptComputeTimeMs\\\":8,\\\"timeSinceIssuedMs\\\":1,\\\"numTokens\\\":0,\\\"compCharLen\\\":2,\\\"numLines\\\":1,\\\"confidence\\\":null,\\\"python\\\":0}\",\"metadataStr\":\"[ERROR] [restraint] [2022-05-29T07:21:03.345Z]\",\"extra\":[\"No value found for meanLogProb -- only got {\\\"promptCharLen\\\":5168,\\\"promptEndPos\\\":17620,\\\"documentLength\\\":28072,\\\"delayMs\\\":0,\\\"promptComputeTimeMs\\\":8,\\\"timeSinceIssuedMs\\\":1,\\\"numTokens\\\":0,\\\"compCharLen\\\":2,\\\"numLines\\\":1,\\\"confidence\\\":null,\\\"python\\\":0}\"]}}Content-Length: 316 {\"jsonrpc\":\"2.0\",\"id\":491,\"result\":{\"completions\":[{\"uuid\":\"a4a4751f-fc25-4da8-b58a-08e05ae71e19\",\"text\":\"returns a list of all tt-rss entries that were missing in elfeed, so\",\"range\":{\"start\":{\"line\":455,\"character\":0},\"end\":{\"line\":455,\"character\":66}},\"displayText\":\"so\",\"position\":{\"line\":455,\"character\":66}}]}}Content-Length: 54 {\"jsonrpc\":\"2.0\",\"id\":492,\"result\":{\"completions\":[]}}" [INFO] Completion: ((error) (completions . [])) [INFO] Completion: ((error) (completions . [])) [INFO] Completion: ((error) (completions . [])) [INFO] Completion: ((error) (completions . [])) [INFO] Completion: ((error) (completions . [])) ```
Stacktrace ```lisp Debugger entered--Lisp error: (wrong-type-argument listp 620) alist-get(result 620) (let* ((result (alist-get 'result content)) (err (alist-get 'error content)) (id (alist-get 'id content))) (if err (progn (copilot--log "[ERROR] Error in response: %S\n[ERROR] Response:%S\n" err content))) (if (not id) (if (equal (alist-get 'method content) "LogMessage") (copilot--log "[Agent] %s" (alist-get 'message (alist-get 'params content))) (copilot--log "[INFO] Discard message without id: %S" content)) (funcall (alist-get id copilot--callbacks) (cons (cons 'error err) result)) (assq-delete-all id copilot--callbacks))) copilot--process-response(620) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))) (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))) (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))))) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))))) (if (and (not header-match) (> (length copilot--output-buffer) 50)) (progn (copilot--log "[Warning] Copilot agent output buffer reset.") (copilot--log "[Warning] Before reset: %S\n" copilot--output-buffer) (setq copilot--output-buffer nil)) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))))))) (let ((header-match (s-match "^Content-Length: \\([0-9]+\\)\15?\n\15?\n" copilot--output-buffer))) (if (and (not header-match) (> (length copilot--output-buffer) 50)) (progn (copilot--log "[Warning] Copilot agent output buffer reset.") (copilot--log "[Warning] Before reset: %S\n" copilot--output-buffer) (setq copilot--output-buffer nil)) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))))))) copilot--process-filter(# nil) (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))) (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))) (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))))) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))))) (if (and (not header-match) (> (length copilot--output-buffer) 50)) (progn (copilot--log "[Warning] Copilot agent output buffer reset.") (copilot--log "[Warning] Before reset: %S\n" copilot--output-buffer) (setq copilot--output-buffer nil)) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil)))))))) (let ((header-match (s-match "^Content-Length: \\([0-9]+\\)\15?\n\15?\n" copilot--output-buffer))) (if (and (not header-match) (> (length copilot--output-buffer) 50)) (progn (copilot--log "[Warning] Copilot agent output buffer reset.") (copilot--log "[Warning] Before reset: %S\n" copilot--output-buffer) (setq copilot--output-buffer nil)) (if header-match (progn (let* ((header (car header-match)) (content-length (string-to-number (car (cdr header-match)))) (full-length (+ (length header) content-length))) (if (>= (length copilot--output-buffer) full-length) (progn (let ((content (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) (length header) full-length) 'utf-8))) (setq copilot--output-buffer (decode-coding-string (substring (encode-coding-string copilot--output-buffer 'raw-text) full-length) 'utf-8)) (let ((content (condition-case nil (progn (json-read-from-string content)) (error nil)))) (if content (copilot--process-response content) (copilot--log "[ERROR] Failed to parse response: %S" content))) (copilot--process-filter process nil))))))))) copilot--process-filter(# "[ERROR] [restraint] [2022-05-29T07:21:03.345Z] No value found for meanLogProb -- only got {\"promptCharLen\":5168,\"promptEndPos\":17620,\"documentLength\":28072,\"delayMs\":0,\"promptComputeTimeMs\":8,\"timeSinceIssuedMs\":1,\"numTokens\":0,\"compCharLen\":2,\"numLi...") ```

I've advised the function for the time being, but that's obviously a bad fix.

(defun my/copilot-process-response-fix (fun content)
  (when (listp content)
    (funcall fun content)))

(advice-add #'copilot--process-response :around #'my/copilot-process-response-fix)

It doesn't seem to affect the availability of completions, although I'm not sure about that.