Fix GeoIP lookup: convert drakma byte response to string

Drakma returns a byte vector, not a string. The code was passing
this directly to cl-json:decode-json-from-string which expects
a string, causing the lookup to silently fail.
This commit is contained in:
Glenn Thompson 2025-12-10 20:28:18 +03:00 committed by Brian O'Reilly
parent f73d0ef007
commit 0748466811
1 changed files with 4 additions and 1 deletions

View File

@ -66,7 +66,10 @@
(handler-case
(let* ((url (format nil *geoip-api-url* ip-address))
(response (drakma:http-request url :want-stream nil))
(data (cl-json:decode-json-from-string response)))
(response-string (if (stringp response)
response
(babel:octets-to-string response :encoding :utf-8)))
(data (cl-json:decode-json-from-string response-string)))
(when (string= (cdr (assoc :status data)) "success")
(list :country-code (cdr (assoc :country-code data))
:city (cdr (assoc :city data))