raven-clj icon indicating copy to clipboard operation
raven-clj copied to clipboard

Ensure UTF-8 encoding

Open Frozenlock opened this issue 5 years ago • 0 comments

On a Windows machine, utf-8 strings passed to raven/capture will not be properly encoded when sent to Sentry.

As far as I can tell, this is because something in the http stack is using the default file encoding. Temporary workaround: Launch the JVM with -Dfile.encoding=utf-8

Potential solution: Explicitly encode the body into utf-8 bytes.

(defn send-packet [{:keys [ts uri project-id key secret] :as packet-info}]
  (let [url (make-sentry-url uri project-id)
        header (make-sentry-header ts key secret)
        body (dissoc packet-info :ts :uri :project-id :key :secret)]
    (http/post url
               {:throw-exceptions false
                :headers {"X-Sentry-Auth" header
                          "User-Agent" sentry-client}
                :body (util/utf8-bytes (json/generate-string body))}))) ; <------

Frozenlock avatar Jan 15 '20 22:01 Frozenlock