Skip to content

Gzip responses not decompressed — invalid character '\x1f' errors #14

@tmchow

Description

@tmchow

The do() method in internal/client/eightsleep.go sets Accept-Encoding: gzip (line 284) but never decompresses the response body. Since the header is set explicitly, Go's http.Client does not auto-decompress. This causes invalid character '\x1f' looking for beginning of value errors on most endpoints (device info, metrics intervals, status, etc.).

$ eightctl device info --quiet
Error: invalid character '\x1f' looking for beginning of value

Fix: Check resp.Header.Get("Content-Encoding") == "gzip" and wrap resp.Body with gzip.NewReader() before decoding:

var respBody io.Reader = resp.Body
if resp.Header.Get("Content-Encoding") == "gzip" {
    gr, err := gzip.NewReader(resp.Body)
    if err == nil {
        defer gr.Close()
        respBody = gr
    }
}

Then use respBody instead of resp.Body for io.ReadAll and json.NewDecoder calls in the same function.

Environment

  • Go 1.25.6, Linux x86_64
  • eightctl built from latest main (Feb 2026)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions