Skip to content

Fix/single base64 encoding - #32

Open
Scarjit wants to merge 5 commits into
mainfrom
fix/single-base64-encoding
Open

Scarjit wants to merge 5 commits into
mainfrom
fix/single-base64-encoding

Conversation

@Scarjit

@Scarjit Scarjit commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Issue

Publisher.Publish base64-encoded each payload before handing it to the API client.
The JSON encoding of []byte encodes it again.
So Go publishers sent double-encoded data.
DecodeString reversed the extra layer, so Go-to-Go traffic looked correct.
Every other client saw base64 text.

Changes

  • Publish and PublishStrings send the raw bytes. The wire carries the payload base64-encoded once, as the API specifies.
  • PullMessage.Data and Bytes() return the original payload.
  • DecodeString and DecodeStrings return the payload as is. Their error is always nil and stays for API compatibility.
  • Pull returns an APIError instead of panicking when a 200 response is not JSON, e.g. a proxy or ingress page.
  • TestWire pins the wire format for publish and pull and covers the non-JSON response. It needs no live environment.

Breaking change

  • Messages from old Go publishers arrive at new consumers as base64 text.
  • Messages from new Go publishers fail in DecodeString on old Go consumers, or yield garbage if the payload happens to be valid base64.
  • Python, Java and k6 clients already encode once. They now interoperate with Go in both directions.

Migration: upgrade the Go publishers and consumers of a topic together, or drain the subscription before upgrading consumers.

Side effect: the payload limit for Go publishers rises from about 4.5 MiB to about 6 MiB raw per message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant