Skip to content

Longer files throws an error #27

Closed
@jcubic

Description

@jcubic

If you open longer file you get an error:

Debugger entered--Lisp error: (wrong-type-argument stringp 413)
  string-trim-right(413 nil)
  string-trim(413)
  (equal "deleted" (string-trim (nth 2 err)))
  (if (equal "deleted" (string-trim (nth 2 err))) nil (save-current-buffer (set-buffer source-buffer) (let* ((c (nthcdr 1 err))) (setcar c (symbol-name (nth 1 err)))) (funcall report-fn :panic :explanation (format "%s: %s" c-buf (error-message-string err)))))
  (cond ((and proc-current err) (if (equal "deleted" (string-trim (nth 2 err))) nil (save-current-buffer (set-buffer source-buffer) (let* ((c (nthcdr 1 err))) (setcar c (symbol-name (nth 1 err)))) (funcall report-fn :panic :explanation (format "%s: %s" c-buf (error-message-string err)))))) ((and proc-current url-http-end-of-headers) (let ((output (save-restriction (set-buffer-multibyte t) (goto-char url-http-end-of-headers) (buffer-substring (point) (point-max))))) (save-current-buffer (set-buffer source-buffer) (funcall report-fn (flymake-languagetool--output-to-errors output source-buffer) :region (cons (point-min) (point-max)))))) ((not proc-current) (save-current-buffer (set-buffer source-buffer) (flymake--log-1 :warning 'flymake-languagetool "Skipping an obsolete check"))))
  (let* ((err (plist-get status :error)) (c-buf (current-buffer)) (proc-buf (buffer-local-value 'flymake-languagetool--proc-buf source-buffer)) (proc-current (equal c-buf proc-buf))) (cond ((and proc-current err) (if (equal "deleted" (string-trim (nth 2 err))) nil (save-current-buffer (set-buffer source-buffer) (let* ((c ...)) (setcar c (symbol-name ...))) (funcall report-fn :panic :explanation (format "%s: %s" c-buf (error-message-string err)))))) ((and proc-current url-http-end-of-headers) (let ((output (save-restriction (set-buffer-multibyte t) (goto-char url-http-end-of-headers) (buffer-substring ... ...)))) (save-current-buffer (set-buffer source-buffer) (funcall report-fn (flymake-languagetool--output-to-errors output source-buffer) :region (cons (point-min) (point-max)))))) ((not proc-current) (save-current-buffer (set-buffer source-buffer) (flymake--log-1 :warning 'flymake-languagetool "Skipping an obsolete check")))) (kill-buffer c-buf))
  flymake-languagetool--handle-finished((:error (error http 413) :peer (:certificates ((:version 3 :serial-number "04:32:23:0d:c0:e2:4b:c5:48:7a:a2:8e:e7:b9:d0:85:85..." :issuer "C=US,O=Let's Encrypt,CN=R3" :valid-from "2024-01-08" :valid-to "2024-04-07" :subject "CN=api.languagetool.org" :public-key-algorithm "EC/ECDSA" :certificate-security-level "High" :signature-algorithm "RSA-SHA256" :public-key-id "sha1:fc:a1:fe:82:43:48:85:8b:68:6e:72:6b:f7:45:d7:..." :certificate-id "sha1:a4:ff:e0:7a:47:de:34:0e:49:2b:13:39:fa:b7:4b:..." :pem "-----BEGIN CERTIFICATE-----\nMIIEKjCCAxKgAwIBAgISBD...") (:version 3 :serial-number "00:91:2b:08:4a:cf:0c:18:a7:53:f6:d6:2e:25:a7:5f:5a" :issuer "C=US,O=Internet Security Research Group,CN=ISRG Ro..." :valid-from "2020-09-04" :valid-to "2025-09-15" :subject "C=US,O=Let's Encrypt,CN=R3" :public-key-algorithm "RSA" :certificate-security-level "Medium" :signature-algorithm "RSA-SHA256" :public-key-id "sha1:8a:93:82:f4:c8:04:08:34:5e:5b:c2:f8:d7:55:d3:..." :certificate-id "sha1:a0:53:37:5b:fe:84:e8:b7:48:78:2c:7c:ee:15:82:..." :pem "-----BEGIN CERTIFICATE-----\nMIIFFjCCAv6gAwIBAgIRAJ...") (:version 3 :serial-number "40:01:77:21:37:d4:e9:42:b8:ee:76:aa:3c:64:0a:b7" :issuer "O=Digital Signature Trust Co.,CN=DST Root CA X3" :valid-from "2021-01-20" :valid-to "2024-09-30" :subject "C=US,O=Internet Security Research Group,CN=ISRG Ro..." :public-key-algorithm "RSA" :certificate-security-level "High" :signature-algorithm "RSA-SHA256" :public-key-id "sha1:f8:16:51:3c:fd:1b:44:9f:2e:6b:28:a1:97:22:1f:..." :certificate-id "sha1:93:3c:6d:de:e9:5c:9c:41:a4:0f:9f:50:49:3d:82:..." :pem "-----BEGIN CERTIFICATE-----\nMIIFYDCCBEigAwIBAgIQQA...")) :certificate (:version 3 :serial-number "04:32:23:0d:c0:e2:4b:c5:48:7a:a2:8e:e7:b9:d0:85:85..." :issuer "C=US,O=Let's Encrypt,CN=R3" :valid-from "2024-01-08" :valid-to "2024-04-07" :subject "CN=api.languagetool.org" :public-key-algorithm "EC/ECDSA" :certificate-security-level "High" :signature-algorithm "RSA-SHA256" :public-key-id "sha1:fc:a1:fe:82:43:48:85:8b:68:6e:72:6b:f7:45:d7:..." :certificate-id "sha1:a4:ff:e0:7a:47:de:34:0e:49:2b:13:39:fa:b7:4b:..." :pem "-----BEGIN CERTIFICATE-----\nMIIEKjCCAxKgAwIBAgISBD...") :key-exchange "ECDHE-RSA" :protocol "TLS1.3" :cipher "AES-256-GCM" :mac "AEAD" :encrypt-then-mac nil)) #<buffer core.md> #f(compiled-function (&rest args) #<bytecode 0x15772c41b62578c4>))
  url-http-activate-callback()
  url-http-content-length-after-change-function(297 407 110)
  url-http-wait-for-headers-change-function(1 416 415)
  url-http-generic-filter(#<process api.languagetool.org> "HTTP/1.1 413 Request Entity Too Large\15\nserver: ngi...")

At least what this library can do is to check the length of the input and don't send the request or catch the exception and give a message "file to long flymake-language tool not enabled".

It would be nice if the text was split and send to API with multiple requests, but it's not ok to just ignore the errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions