nyyManni / jiralib2

Lisp bindings to JIRA REST API (used by Ejira)
GNU General Public License v3.0
21 stars 21 forks source link

request problems #12

Open MadEarl opened 2 years ago

MadEarl commented 2 years ago

Hi,

I've for a while been experiencing problems with requests against JIRA Cloud.

When using the default curl backend of request, I'm running into what seems to be a race condition when updating the Ejira agenda. At some point, the update process fails with the error »semaphore never called«.

When instead using url-retrieve as request backend, the update process works fine (and much quicker than with curl for some reason), but I get botched encoding in Org. I traced the error back to this function, where replacing 'no-conversion with 'cp1252 (wtf?) fixes the issue:

(defun request--parse-data (response encoding parser)
  "In RESPONSE buffer, decode via ENCODING, then send to PARSER."
  (let ((buffer (request-response--buffer response)))
    (when (buffer-live-p buffer)
      (with-current-buffer buffer
        (request-log 'trace "request--parse-data: %s" (buffer-string))
        (unless (eq (request-response-status-code response) 204)
          (recode-region (point-min) (point-max) encoding 'cp1252) ; <-- Jira sending Windows-1252?
          (goto-char (point-min))
          (setf (request-response-data response)
                (if parser (funcall parser) (buffer-string))))))))

This is of course just a hack, but I don't know how to proceed from here. Any suggestions? I'm on Emacs 28.1, BTW, with the latest request.el from Elpa, request-20221004.1331 as of this writing.

MadEarl commented 1 year ago

The non-hacky fix is to wrap all :data fields in (encode-coding-string ... 'utf-8). This way, sync works flawlessly with the url-retrieve backend, which, at least with my setup, is much quicker than curl and, most importantly, does not fail.