Skip to content

Commit 2ad406a

Browse files
committed
rlm_kafka: recognise a null key box on the xlat path
With the framework now carrying FR_TYPE_NULL boxes through to the xlat body, check for fr_type_is_null() in addition to the zero-length check so an explicit `null` key, an empty '' literal, and an attribute that expanded to nothing all resolve to "no key on the wire" without any of them needing to coerce into a zero-length octets value.
1 parent 2bfa768 commit 2ad406a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/modules/rlm_kafka/rlm_kafka.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,12 @@ static xlat_action_t kafka_xlat_produce(UNUSED TALLOC_CTX *xctx_ctx, UNUSED fr_d
805805
}
806806

807807
/*
808-
* Zero-length octets (e.g. `''` or an attribute expanding
809-
* to nothing) map to "no key" on the wire - librdkafka then
810-
* uses the configured partitioner instead of key-hash
811-
* partitioning.
808+
* Explicit `null`, a zero-length octets literal, or an
809+
* attribute expanding to nothing all map to "no key" on
810+
* the wire - librdkafka then uses the configured
811+
* partitioner instead of key-hash partitioning.
812812
*/
813-
if (key_vb->vb_length > 0) {
813+
if (!fr_type_is_null(key_vb->type) && key_vb->vb_length > 0) {
814814
key = key_vb->vb_octets;
815815
key_len = key_vb->vb_length;
816816
}

0 commit comments

Comments
 (0)