You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by "almostintuitive (via GitHub)" <gi...@apache.org> on 2026/10/09 05:20:37 UTC

[I] Go SDK: NewIggyMessage accepts empty or oversized user header values; readers then drop all headers of the message [iggy]

almostintuitive opened a new issue, #4471:
URL: https://github.com/apache/iggy/issues/4471

   ## Bug description
   
   The Go SDK sends user headers that break the header wire format, and readers
   then lose every header on that message.
   
   The format bounds every key and value to 1..=255 bytes, and a fixed-size kind
   (`Int32`, `Uint64`, `Bool`, ...) to its exact width
   (`core/binary_protocol/src/primitives/user_headers.rs`, `validate_user_headers`).
   The Rust SDK (`HeaderField::from_raw`, the `TryFrom` impls), Java (`HeaderValue`)
   and Node (`header.utils.ts`) refuse such a header when it is built. The Go
   `MaxUserHeadersSize` doc says "each individual header value is limited to 255
   bytes", but nothing enforces it. `HeaderValue` and `HeaderKey` are plain structs,
   and `NewIggyMessage(payload, WithUserHeaders(...))` serializes whatever it is given:
   
   - an empty value (`HeaderValue{Kind: String, Value: []byte{}}`, for example from an
     empty string field)
   - a value or key longer than 255 bytes
   - a fixed-size kind with the wrong width (`Int32` with 3 bytes)
   
   The server stores header bytes as sent. It cannot check them in general, because
   producers may encrypt user headers client-side (`core/sdk/src/clients/producer.rs`).
   So the bad header reaches every consumer:
   
   - Rust: `IggyMessage::user_headers_map()` fails `WireUserHeaders::from_bytes`, logs
     a warning, and returns `Ok(None)`. All headers of that message read as absent,
     not just the empty one, so `get_user_header` returns `None` for keys that were sent.
   - The Go SDK's own `DeserializeHeaders` rejects the bytes its encoder produced
     ("value has incorrect size, must be between 1 and 255").
   
   ## Reproduction
   
   Server `apache/iggy:edge` (master `09420cf4d`), Go SDK from the same commit:
   
   ```go
   key, _ := iggcon.NewHeaderKeyString("dedup-key")
   msg, err := iggcon.NewIggyMessage([]byte("payload"),
       iggcon.WithUserHeaders([]iggcon.HeaderEntry{{Key: key,
           Value: iggcon.HeaderValue{Kind: iggcon.String, Value: []byte{}}}}))
   // err == nil; msg.UserHeaders = 02 09000000 "dedup-key" 02 00000000
   _, err = client.SendMessages(ctx, stream, topic, iggcon.PartitionId(0), []iggcon.IggyMessage{msg})
   // err == nil: the server stores it
   ```
   
   `iggy message poll --offset 0 --show-headers <stream> <topic> 0` then shows the
   `dedup-key` column empty for that message, and filled for a message sent with
   `--headers dedup-key:string:abc`. A Go poll returns the same header bytes back.
   `DeserializeHeaders` on them fails.
   
   ## Expected behavior
   
   `NewIggyMessage` returns `ErrInvalidHeaderKey` / `ErrInvalidHeaderValue` for a
   header that `DeserializeHeaders` (and the Rust reader) would refuse, as Rust, Java
   and Node already do when the header is built.
   
   Separately, the Rust reader might surface the decode error instead of
   `Ok(None)`. Today a malformed header looks the same as no headers.
   
   ## Failing test
   
   A PR follows with `TestNewIggyMessage_HeadersItAcceptsAreDecodable` in
   `foreign/go/contracts`. Any header `NewIggyMessage` accepts must round-trip
   through `DeserializeHeaders`. 6 malformed cases fail on master, 3 well-formed
   cases pass.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Go SDK: NewIggyMessage accepts empty or oversized user header values; readers then drop all headers of the message [iggy]

Posted by "spetz (via GitHub)" <gi...@apache.org>.
spetz closed issue #4471: Go SDK: NewIggyMessage accepts empty or oversized user header values; readers then drop all headers of the message
URL: https://github.com/apache/iggy/issues/4471


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org