public inbox for kaagum@systemreboot.net
 help / color / mirror / Atom feed
* [PATCH] Remove #:streaming? #t from HTTP requests to fix JSON parsing
@ 2026-07-20 14:21 jgart
  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
  0 siblings, 2 replies; 9+ messages in thread
From: jgart @ 2026-07-20 14:21 UTC (permalink / raw)
  To: kaagum

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-08-14 13:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-20 14:21 [PATCH] Remove #:streaming? #t from HTTP requests to fix JSON parsing jgart
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox