mpedramfar / zotra

GNU General Public License v3.0
170 stars 5 forks source link

error "Multibyte text in HTTP request" #12

Closed benthamite closed 1 year ago

benthamite commented 1 year ago

After updating to the latest version, I’m getting a "Multibyte text in HTTP request" error; I append a backtrace.

Here’s the relevant part of my config:

  (setq zotra-use-curl nil)
  (setq zotra-url-retrieve-timeout 10)
  (setq zotra-default-entry-format "biblatex")
  (setq zotra-after-add-entry-hook nil)
  (setq zotra-download-attachment-default-directory "~/Downloads/")
  (setq zotra-backend 'translation-server)
  (setq zotra-cli-command `("node" ,(file-name-concat ps/dir-dropbox "source/zotra-cli/bin/index.js")))

I’m using the latest version of translation-server (commit #cf96d57).

I’m not sure what’s going on, and GPT-4 doesn’t, either. Let me know if there’s other information I could provide to help diagnose the problem. Thank you.

Debugger entered--Lisp error: (error "Multibyte text in HTTP request: POST /export?format=biblatex HTTP/1.1\15\nMIME-Version: 1.0\15\nConnection: keep-alive\15\nHost: 127.0.0.1:1969\15\nAccept-encoding: gzip\15\nAccept: */*\15\nUser-Agent: URL/Emacs Emacs/30.0.50 (OpenStep; aarch64-apple-darwin22.5.0)\15\nContent-Type: application/json\15\nContent-length: 955\15\n\15\n[{\"key\":\"5WVSPXHA\",\"version\":0,\"itemType\":\"newspaperArticle\",\"creators\":[{\"firstName\":\"Patrick\",\"lastName\":\"Kingsley\",\"creatorType\":\"author\"},{\"firstName\":\"Isabel\",\"lastName\":\"Kershner\",\"creatorType\":\"author\"}],\"tags\":[{\"tag\":\"Israel\",\"type\":1},{\"tag\":\"Gaza Strip\",\"type\":1},{\"tag\":\"Hamas\",\"type\":1},{\"tag\":\"War and Armed Conflicts\",\"type\":1},{\"tag\":\"Israel-Gaza War (2023- )\",\"type\":1}],\"title\":\"Israel-Gaza War: ‘This Is Terrorism’: Biden Condemns Hamas Attacks in Israel\",\"section\":\"World\",\"date\":\"2023-10-10\",\"url\":\"https://www.nytimes.com/live/2023/10/10/world/israel-hamas-war-gaza\",\"abstractNote\":\"Speaking from the White House, President Biden said 14 Americans had been killed during Hamas’s incursions into Israel and that some U.S. citizens were being held hostage.\",\"language\":\"en-US\",\"libraryCatalog\":\"NYTimes.com\",\"accessDate\":\"2023-10-10T20:15:22Z\",\"publicationTitle\":\"The New York Times\",\"ISSN\":\"0362-4331\",\"shortTitle\":\"Israel-Gaza War\"}]")
  error("Multibyte text in HTTP request: %s" "POST /export?format=biblatex HTTP/1.1\15\nMIME-Version: 1.0\15\nConnection: keep-alive\15\nHost: 127.0.0.1:1969\15\nAccept-encoding: gzip\15\nAccept: */*\15\nUser-Agent: URL/Emacs Emacs/30.0.50 (OpenStep; aarch64-apple-darwin22.5.0)\15\nContent-Type: application/json\15\nContent-length: 955\15\n\15\n[{\"key\":\"5WVSPXHA\",\"version\":0,\"itemType\":\"newspaperArticle\",\"creators\":[{\"firstName\":\"Patrick\",\"lastName\":\"Kingsley\",\"creatorType\":\"author\"},{\"firstName\":\"Isabel\",\"lastName\":\"Kershner\",\"creatorType\":\"author\"}],\"tags\":[{\"tag\":\"Israel\",\"type\":1},{\"tag\":\"Gaza Strip\",\"type\":1},{\"tag\":\"Hamas\",\"type\":1},{\"tag\":\"War and Armed Conflicts\",\"type\":1},{\"tag\":\"Israel-Gaza War (2023- )\",\"type\":1}],\"title\":\"Israel-Gaza War: ‘This Is Terrorism’: Biden Condemns Hamas Attacks in Israel\",\"section\":\"World\",\"date\":\"2023-10-10\",\"url\":\"https://www.nytimes.com/live/2023/10/10/world/israel-hamas-war-gaza\",\"abstractNote\":\"Speaking from the White House, President Biden said 14 Americans had been killed during Hamas’s incursions into Israel and that some U.S. citizens were being held hostage.\",\"language\":\"en-US\",\"libraryCatalog\":\"NYTimes.com\",\"accessDate\":\"2023-10-10T20:15:22Z\",\"publicationTitle\":\"The New York Times\",\"ISSN\":\"0362-4331\",\"shortTitle\":\"Israel-Gaza War\"}]")
  url-http-create-request()
  url-http(#s(url :type "http" :user nil :password nil :host "127.0.0.1" :portspec 1969 :filename "/export?format=biblatex" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous nil) #f(compiled-function (&rest args) #<bytecode 0xcd6cafbfa3f6eef>) (nil))
  url-retrieve-internal("http://127.0.0.1:1969/export?format=biblatex" #f(compiled-function (&rest args) #<bytecode 0xcd6cafbfa3f6eef>) (nil) nil nil)
  url-retrieve("http://127.0.0.1:1969/export?format=biblatex" #f(compiled-function (&rest args) #<bytecode 0xcd6cafbfa3f6eef>) nil nil nil)
  url-retrieve-synchronously("http://127.0.0.1:1969/export?format=biblatex" nil nil 10)
  zotra-retrieve-synchronously("http://127.0.0.1:1969/export?format=biblatex" (("Content-Type" . "application/json")) "[{\"key\":\"5WVSPXHA\",\"version\":0,\"itemType\":\"newspaperArticle\",\"creators\":[{\"firstName\":\"Patrick\",\"lastName\":\"Kingsley\",\"creatorType\":\"author\"},{\"firstName\":\"Isabel\",\"lastName\":\"Kershner\",\"creatorType\":\"author\"}],\"tags\":[{\"tag\":\"Israel\",\"type\":1},{\"tag\":\"Gaza Strip\",\"type\":1},{\"tag\":\"Hamas\",\"type\":1},{\"tag\":\"War and Armed Conflicts\",\"type\":1},{\"tag\":\"Israel-Gaza War (2023- )\",\"type\":1}],\"title\":\"Israel-Gaza War: ‘This Is Terrorism’: Biden Condemns Hamas Attacks in Israel\",\"section\":\"World\",\"date\":\"2023-10-10\",\"url\":\"https://www.nytimes.com/live/2023/10/10/world/israel-hamas-war-gaza\",\"abstractNote\":\"Speaking from the White House, President Biden said 14 Americans had been killed during Hamas’s incursions into Israel and that some U.S. citizens were being held hostage.\",\"language\":\"en-US\",\"libraryCatalog\":\"NYTimes.com\",\"accessDate\":\"2023-10-10T20:15:22Z\",\"publicationTitle\":\"The New York Times\",\"ISSN\":\"0362-4331\",\"shortTitle\":\"Israel-Gaza War\"}]")
  zotra-contact-server("[{\"key\":\"5WVSPXHA\",\"version\":0,\"itemType\":\"newspaperArticle\",\"creators\":[{\"firstName\":\"Patrick\",\"lastName\":\"Kingsley\",\"creatorType\":\"author\"},{\"firstName\":\"Isabel\",\"lastName\":\"Kershner\",\"creatorType\":\"author\"}],\"tags\":[{\"tag\":\"Israel\",\"type\":1},{\"tag\":\"Gaza Strip\",\"type\":1},{\"tag\":\"Hamas\",\"type\":1},{\"tag\":\"War and Armed Conflicts\",\"type\":1},{\"tag\":\"Israel-Gaza War (2023- )\",\"type\":1}],\"title\":\"Israel-Gaza War: ‘This Is Terrorism’: Biden Condemns Hamas Attacks in Israel\",\"section\":\"World\",\"date\":\"2023-10-10\",\"url\":\"https://www.nytimes.com/live/2023/10/10/world/israel-hamas-war-gaza\",\"abstractNote\":\"Speaking from the White House, President Biden said 14 Americans had been killed during Hamas’s incursions into Israel and that some U.S. citizens were being held hostage.\",\"language\":\"en-US\",\"libraryCatalog\":\"NYTimes.com\",\"accessDate\":\"2023-10-10T20:15:22Z\",\"publicationTitle\":\"The New York Times\",\"ISSN\":\"0362-4331\",\"shortTitle\":\"Israel-Gaza War\"}]" "application/json" "export" ("format" . "biblatex"))
  zotra-get-entry-from-json("[{\"key\":\"5WVSPXHA\",\"version\":0,\"itemType\":\"newspaperArticle\",\"creators\":[{\"firstName\":\"Patrick\",\"lastName\":\"Kingsley\",\"creatorType\":\"author\"},{\"firstName\":\"Isabel\",\"lastName\":\"Kershner\",\"creatorType\":\"author\"}],\"tags\":[{\"tag\":\"Israel\",\"type\":1},{\"tag\":\"Gaza Strip\",\"type\":1},{\"tag\":\"Hamas\",\"type\":1},{\"tag\":\"War and Armed Conflicts\",\"type\":1},{\"tag\":\"Israel-Gaza War (2023- )\",\"type\":1}],\"title\":\"Israel-Gaza War: ‘This Is Terrorism’: Biden Condemns Hamas Attacks in Israel\",\"section\":\"World\",\"date\":\"2023-10-10\",\"url\":\"https://www.nytimes.com/live/2023/10/10/world/israel-hamas-war-gaza\",\"abstractNote\":\"Speaking from the White House, President Biden said 14 Americans had been killed during Hamas’s incursions into Israel and that some U.S. citizens were being held hostage.\",\"language\":\"en-US\",\"libraryCatalog\":\"NYTimes.com\",\"accessDate\":\"2023-10-10T20:15:22Z\",\"publicationTitle\":\"The New York Times\",\"ISSN\":\"0362-4331\",\"shortTitle\":\"Israel-Gaza War\"}]" "biblatex")
  zotra-get-entry-1("https://www.nytimes.com/live/2023/10/10/world/israel-hamas-war-gaza" "biblatex" "web")
  zotra-get-entry(nil nil)
  zotra-add-entry()
  funcall-interactively(zotra-add-entry)
  command-execute(zotra-add-entry record)
  execute-extended-command(nil "zotra-add-entry" nil)
  funcall-interactively(execute-extended-command nil "zotra-add-entry" nil)
  command-execute(execute-extended-command)
mpedramfar commented 1 year ago

Seems like this issue: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23750#29 The last commit should solve it. Feel free to reopen if the issue persists.

mpedramfar commented 1 year ago

By the way, you seem to be using two backends at the same time. It makes sense to use translation-server to get entries and zotra-cli to get attachments, because translation-server is much faster.

I added a backend zotra-server which is as fast as translation-server and can also get attachments. I also added the functionality of running the servers from inside emacs, so you won't need to run it externally. Note that zotra-cli repository is also updated (and renamed to zotra-server)

benthamite commented 1 year ago

I just tried it and it works great. Thank you!

benthamite commented 1 year ago

By the way, perhaps a user option should be added to always run zotra-download-attachment after zotra-add-entry, passing to it the same URL or search string?

mpedramfar commented 1 year ago

I'm considering it. First I'd need to change a few things to make the current code cleaner before adding that.