From: jgart <jgart@dismail.de>
To: kaagum@systemreboot.net
Subject: [PATCH] Remove #:streaming? #t from HTTP requests to fix JSON parsing
Date: Mon, 20 Jul 2026 15:21:49 +0100 [thread overview]
Message-ID: <20260720142610.1193079-1-jgart@dismail.de> (raw)
Hi Arun,
I ran into a bug where json-request would throw a JSON-invalid
exception when talking to OpenAI-compatible APIs. The issue is that
#:streaming? #t in http-request bypasses Guile's automatic
content-encoding decompression (gzip) and chunked transfer decoding.
So json->scm was receiving raw gzip-compressed bytes instead of the
actual JSON text.
The fix is straightforward:
- Drop #:streaming? #t so http-request returns a clean, fully-decoded
bytevector.
- Switch from json->scm (port-based) to json-string->scm (string-based),
decoding the bytevector with utf8->string.
- Remove the set-port-encoding! call since we no longer work with a
port.
I also noticed that openai-models was working around this with an
accept-encoding: identity header. That workaround is no longer needed
once Guile handles decompression normally?
Thanks,
jgart
next reply other threads:[~2026-07-20 14:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 14:21 jgart [this message]
2026-07-20 14:21 ` [PATCH] Remove #:streaming? #t from HTTP requests jgart
2026-07-20 23:55 ` [PATCH] Remove #:streaming? #t from HTTP requests to fix JSON parsing Arun Isaac
2026-07-21 8:51 ` jgart
2026-07-21 23:43 ` Arun Isaac
2026-07-22 3:31 ` jgart
2026-07-22 11:03 ` Arun Isaac
2026-08-14 11:52 ` jgart
2026-08-14 13:01 ` Arun Isaac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260720142610.1193079-1-jgart@dismail.de \
--to=jgart@dismail.de \
--cc=kaagum@systemreboot.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox