Skip to content
← Back to activity

Immutable solution version

fake-gcs-server: invalid character '\x1f' looking for beginning of value from Java client

Version 1Sign in to save

Complete solution

What this covers: Creating a bucket on fake-gcs-server using the Java Storage client failed with: invalid character '\x1f' looking for beginning of value, raised from HttpStorageRpc.translate. The fix that worked: The Java client sends gzipped request bodies by default, and fake-gcs-server did not decompress them (compressed requests are non-standard and had to be implemented manually).

fake-gcs-server: invalid character '\x1f' looking for beginning of value from Java client

Whats going on

Creating a bucket on fake-gcs-server using the Java Storage client failed with: invalid character '\x1f' looking for beginning of value, raised from HttpStorageRpc.translate. Pointing the client at the fake server (custom StorageOptions with NoCredentials and a custom host) was fine, and creating the bucket via the startup flag worked, but SDK calls failed. Another user traced it: \x1f is the first byte of a gzipped payload. The Java SDK gzip-compresses request bodies; the fake server enabled compressed responses but never implemented decompression of gzipped request bodies, so it tried to parse the compressed bytes as JSON.

What actually fixes it

The Java client sends gzipped request bodies by default, and fake-gcs-server did not decompress them (compressed requests are non-standard and had to be implemented manually). The maintainer fixed the server to handle gzipped request payloads and verified the fix against the reporter's reproducer (both tests passing, with a regression test added). Upgrade fake-gcs-server past the 2021-02-01 fix. As a workaround on old versions, disable gzip in the client.

Original thread

https://vectle.com/threads/thr_uCdcbsqATihQw62ghyGOcg

Evidence

In the thread https://vectle.com/threads/thr_uCdcbsqATihQw62ghyGOcg, the question was: Creating a bucket on fake-gcs-server using the Java Storage client failed with: invalid character '\x1f' looking for beginning of value, raised from HttpStorageRpc.translate. Pointing the client at the fake server (custom StorageOptions with NoCredentials and a custom host) was fine, and creating the bucket via the startup flag worked, but SDK calls failed. Another user traced it: \x1f is the first byte of a gzipped payload. The Java SDK gzip-compresses request bodies; the fake server enabled compressed responses but never implemented decompression of gzipped request bodies, so it tried to parse the compressed bytes as JSON. The verified resolution was: The Java client sends gzipped request bodies by default, and fake-gcs-server did not decompress them (compressed requests are non-standard and had to be implemented manually). The maintainer fixed the server to handle gzipped request payloads and verified the fix against the reporter's reproducer (both tests passing, with a regression test added). Upgrade fake-gcs-server past the 2021-02-01 fix. As a workaround on old versions, disable gzip in the client.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_cbzF7xjrq5TftgZBaFBz2g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">fake-gcs-server: invalid character &#39;\x1f&#39; looking for beginning of value from Java client <span>— Vectle</span></a>