streamstack icon indicating copy to clipboard operation
streamstack copied to clipboard

[question] What does picomq mean by ordered headers?

Open aaronS7 opened this issue 2 months ago • 7 comments

Question

According to this part of the docs https://github.com/picomq/picomq/blob/aa02bb9c25f0c44cb01203b80504023c46448a53/website/pages/docs/design/protocols.md?plain=1#L36 It talks briefly about ordered headers. Does that mean there are able to be duplicate headers? Or does the last header of the "duplicate" header win? Curious what the expected behavior is

Context


aaronS7 avatar Sep 06 '26 22:09 aaronS7

Hi @aaronS7, in this context, the ordered headers is per Kafka list semantics (Record V2), a sequence of named byte values, order preserved and duplicate names allowed. The log does not apply last-wins.

But a good indicator to clarify that in the docs. I'll have that updated.

addu390 avatar Sep 06 '26 22:09 addu390

Gotcha, I asked because I was exploring some examples and I found a few use cases where duplicate headers were not preserved. I will post those shortly to see if you think that is working as intended or if I should file an issue

aaronS7 avatar Sep 06 '26 23:09 aaronS7

With Kafka protocol, both produce and consume should preserve the headers as-is. But a few other surfaces such as HTTP and SDK/Clients, decodes to IndexMap first, in which case last-one-wins would be correct.

Nonetheless, do share the surface path you are testing and it should be a quick fix-or-expected decision.

addu390 avatar Sep 06 '26 23:09 addu390

So using an example like

await client.append(stream, [{
  key: 'key',
  body: 'body',
  headerPairs: [
    ['duplicate', 'first\0'],
    ['other', new Uint8Array([0xff])],
    ['duplicate', 'last'],
  ],
}], { signal: AbortSignal.timeout(10_000) });

The duplicate header would be lost for the first entry. So instead of three headers, there would only be two

aaronS7 avatar Sep 07 '26 03:09 aaronS7

Thanks for sharing, currently this is expected behaviour for HTTP endpoints, both PicoMQ and Durable Streams protocol. That said, do you see a use case where duplicates should be allowed?

addu390 avatar Sep 07 '26 13:09 addu390

I don't, to be headers are key value and should be unique. But my coding agent flagged it while I was experimenting with something else. Figured I'd bring it up since I think it focused a lot on the ordered header semantics. Fee free to close and thanks for answering!

aaronS7 avatar Sep 07 '26 13:09 aaronS7

Got it, thanks for reporting. Then the take away would be to correctly document the behaviour. I have a ongoing PR for a few docs improvements, I'll add this on over there.

addu390 avatar Sep 07 '26 13:09 addu390