Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken response parsing in some cases #62

Open
bigodel opened this issue Dec 14, 2023 · 1 comment
Open

Broken response parsing in some cases #62

bigodel opened this issue Dec 14, 2023 · 1 comment

Comments

@bigodel
Copy link
Contributor

bigodel commented Dec 14, 2023

To be honest, I'm not sure when or why this happens, but apparently some requests break Verb's response. I get the following warnings in *Messages*:

Warning: Unknown type: verb--http-method
Warning: Unknown type: verb--http-headers [3 times]
Warning: Unknown type: verb--http-method
Warning: Unknown type: verb--http-headers [2 times]
Warning: Unknown type: verb--http-method
Warning: Unknown type: verb--http-headers
GET request sent to https://foo.bar
nil | GET https://foo.bar

As you can see, it doesn't even parse the response status. That's using verb-request-on-point-no-window, if I'm using any command that creates a buffer to display the response (or ob-verb--send-request) I get the following error:

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
  insert(nil "\n")
  (progn (print resp) (insert (eieio-oref resp 'status) "\n") (verb--insert-header-contents (eieio-oref resp 'headers)) (insert "\n") (if (eieio-oref resp 'body) (progn (insert "\n") (insert-buffer-substring buf))) (verb--buffer-string-no-properties))
  (unwind-protect (progn (print resp) (insert (eieio-oref resp 'status) "\n") (verb--insert-header-contents (eieio-oref resp 'headers)) (insert "\n") (if (eieio-oref resp 'body) (progn (insert "\n") (insert-buffer-substring buf))) (verb--buffer-string-no-properties)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (print resp) (insert (eieio-oref resp 'status) "\n") (verb--insert-header-contents (eieio-oref resp 'headers)) (insert "\n") (if (eieio-oref resp 'body) (progn (insert "\n") (insert-buffer-substring buf))) (verb--buffer-string-no-properties)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (print resp) (insert (eieio-oref resp 'status) "\n") (verb--insert-header-contents (eieio-oref resp 'headers)) (insert "\n") (if (eieio-oref resp 'body) (progn (insert "\n") (insert-buffer-substring buf))) (verb--buffer-string-no-properties)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  (progn (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (print resp) (insert (eieio-oref resp 'status) "\n") (verb--insert-header-contents (eieio-oref resp 'headers)) (insert "\n") (if (eieio-oref resp 'body) (progn (insert "\n") (insert-buffer-substring buf))) (verb--buffer-string-no-properties)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))
  (closure (t) (resp buf) "Return HTTP response RESP as a string.\nBUF is the ..." (progn (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (print resp) (insert ... "\n") (verb--insert-header-contents ...) (insert "\n") (if ... ...) (verb--buffer-string-no-properties)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))))(#<verb-response verb-response-15655e0712ec> #<buffer *HTTP Response*>)
  apply((closure (t) (resp buf) "Return HTTP response RESP as a string.\nBUF is the ..." (progn (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (print resp) (insert ... "\n") (verb--insert-header-contents ...) (insert "\n") (if ... ...) (verb--buffer-string-no-properties)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))) #<verb-response verb-response-15655e0712ec> #<buffer *HTTP Response*>)
  verb-response-to-string(#<verb-response verb-response-15655e0712ec> #<buffer *HTTP Response*>)
  (let nil (verb-response-to-string verb-http-response buf))
  (cond ((null part) (let nil (verb-response-to-string verb-http-response buf))) ((equal part '"get-body") (let nil (verb--buffer-string-no-properties))) ((equal part '"get-headers") (let nil (let ((headers (eieio-oref verb-http-response 'headers))) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ... ...) (and ... ...))))))))
  (if (eq verb-http-response t) (format "(Request timed out after %.4g seconds)" (- (time-to-seconds) start)) (cond ((null part) (let nil (verb-response-to-string verb-http-response buf))) ((equal part '"get-body") (let nil (verb--buffer-string-no-properties))) ((equal part '"get-headers") (let nil (let ((headers (eieio-oref verb-http-response ...))) (let ((temp-buffer ...)) (save-current-buffer (set-buffer temp-buffer) (unwind-protect ... ...))))))))
  (save-current-buffer (set-buffer buf) (if (eq verb-http-response t) (format "(Request timed out after %.4g seconds)" (- (time-to-seconds) start)) (cond ((null part) (let nil (verb-response-to-string verb-http-response buf))) ((equal part '"get-body") (let nil (verb--buffer-string-no-properties))) ((equal part '"get-headers") (let nil (let ((headers ...)) (let (...) (save-current-buffer ... ...))))))))
  (let* ((start (time-to-seconds)) (buf (verb--request-spec-send rs nil))) (print buf) (while (and (eq (buffer-local-value 'verb-http-response buf) t) (< (- (time-to-seconds) start) verb-babel-timeout)) (sleep-for 0.1)) (save-current-buffer (set-buffer buf) (if (eq verb-http-response t) (format "(Request timed out after %.4g seconds)" (- (time-to-seconds) start)) (cond ((null part) (let nil (verb-response-to-string verb-http-response buf))) ((equal part '"get-body") (let nil (verb--buffer-string-no-properties))) ((equal part '"get-headers") (let nil (let (...) (let ... ...))))))))
  ob-verb--send-request(#<verb-request-spec verb-request-spec-15655919db06> nil)
  org-babel-execute:verb("GET /failed-events" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:results . "replace") (:exports . "code") (:session . "none") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no") (:wrap . "src ob-verb-response")))
  #<subr org-babel-execute-src-block>(nil ("verb" "GET /failed-events" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:results . "replace") (:exports . "code") (:wrap . "src ob-verb-response") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 7286 "(ref:%s)") nil nil)
  apply(#<subr org-babel-execute-src-block> (nil ("verb" "GET /failed-events" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:results . "replace") (:exports . "code") (:wrap . "src ob-verb-response") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 7286 "(ref:%s)")))
  org-babel-execute-src-block(nil ("verb" "GET /failed-events" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:results . "replace") (:exports . "code") (:wrap . "src ob-verb-response") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 7286 "(ref:%s)"))
  org-ctrl-c-ctrl-c(nil)
  funcall-interactively(org-ctrl-c-ctrl-c nil)
  command-execute(org-ctrl-c-ctrl-c)

I don't have a clue what's going on

@federicotdn
Copy link
Owner

Strange! Is there more information about the how the request looked like? Or the server handling the request?
Did it happen consistently more times?

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

No branches or pull requests

2 participants