Impact
Users configuring the OTel Kafka partitioner with hash mode and reachable_only: true do not get the configured behavior unless they also set hash fields. This silently changes partitioning consistency semantics and can cause blocked/retried publishes against unavailable partitions.
Reproduction Steps
Create x-pack/otel/extension/kafkapartitionerextension/repro_reachable_only_test.go with the following test:
package kafkapartitionerextension
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/twmb/franz-go/pkg/kgo"
)
func TestHashPartitionerReachableOnlyRespected (t * testing.T ) {
_ , tp := getPartitioner (t , map [string ]any {
"hash" : map [string ]any {
"reachable_only" : true ,
},
})
assert .False (
t ,
tp .RequiresConsistency (& kgo.Record {}),
"`reachable_only: true` should disable strict consistency requirement" ,
)
}
Run:
go test ./x-pack/otel/extension/kafkapartitionerextension -run TestHashPartitionerReachableOnlyRespected -count=1
Expected vs Actual
Expected: reachable_only: true is respected for hash partitioning regardless of whether hash field list is provided.
Actual: Test fails; RequiresConsistency remains true.
Actual output:
--- FAIL: TestHashPartitionerReachableOnlyRespected (0.00s)
repro_reachable_only_test.go:21:
Error Trace: /home/runner/work/beats/beats/x-pack/otel/extension/kafkapartitionerextension/repro_reachable_only_test.go:21
Error: Should be false
Test: TestHashPartitionerReachableOnlyRespected
Messages: `reachable_only: true` should disable strict consistency requirement
FAIL
FAIL github.com/elastic/beats/v7/x-pack/otel/extension/kafkapartitionerextension 0.007s
FAIL
Failing Test
package kafkapartitionerextension
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/twmb/franz-go/pkg/kgo"
)
func TestHashPartitionerReachableOnlyRespected (t * testing.T ) {
_ , tp := getPartitioner (t , map [string ]any {
"hash" : map [string ]any {
"reachable_only" : true ,
},
})
assert .False (
t ,
tp .RequiresConsistency (& kgo.Record {}),
"`reachable_only: true` should disable strict consistency requirement" ,
)
}
Evidence
x-pack/otel/extension/kafkapartitionerextension/partitioner.go:52-57 parses reachable_only into reachable.Reachable.
x-pack/otel/extension/kafkapartitionerextension/partitioner.go:138-140 returns makeHashKgoPartitioner() when len(conf.Hash) == 0, bypassing reachable.
x-pack/otel/extension/kafkapartitionerextension/partitioner.go:142-144 applies reachable only when hash fields are configured.
x-pack/otel/extension/kafkapartitionerextension/partitioner.go:224 defines consistency semantics via RequiresConsistency(*kgo.Record) bool { return !b.requireConsistency }.
This makes reachable_only effective for one hash code path but ignored for the no-fields hash path.
Warning
⚠️ Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network :
allowed :
- defaults
- " 169.254.169.254"
See Network Configuration for more information.
Note
🔒 Integrity filter blocked 3 items
The following items were blocked because they don't meet the GitHub integrity level.
#2626 search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
#50226 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
#12867 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
To allow these resources, lower min-integrity in your GitHub frontmatter:
tools :
github :
min-integrity : approved # merged | approved | unapproved | none
What is this? | From workflow: Bug Hunter
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
Impact
Users configuring the OTel Kafka partitioner with
hashmode andreachable_only: truedo not get the configured behavior unless they also sethashfields. This silently changes partitioning consistency semantics and can cause blocked/retried publishes against unavailable partitions.Reproduction Steps
x-pack/otel/extension/kafkapartitionerextension/repro_reachable_only_test.gowith the following test:go test ./x-pack/otel/extension/kafkapartitionerextension -run TestHashPartitionerReachableOnlyRespected -count=1Expected vs Actual
Expected:
reachable_only: trueis respected for hash partitioning regardless of whetherhashfield list is provided.Actual: Test fails;
RequiresConsistencyremains true.Actual output:
Failing Test
Evidence
x-pack/otel/extension/kafkapartitionerextension/partitioner.go:52-57parsesreachable_onlyintoreachable.Reachable.x-pack/otel/extension/kafkapartitionerextension/partitioner.go:138-140returnsmakeHashKgoPartitioner()whenlen(conf.Hash) == 0, bypassingreachable.x-pack/otel/extension/kafkapartitionerextension/partitioner.go:142-144appliesreachableonly when hash fields are configured.x-pack/otel/extension/kafkapartitionerextension/partitioner.go:224defines consistency semantics viaRequiresConsistency(*kgo.Record) bool { return !b.requireConsistency }.This makes
reachable_onlyeffective for one hash code path but ignored for the no-fields hash path.Warning
The following domain was blocked by the firewall during workflow execution:
169.254.169.254To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Note
🔒 Integrity filter blocked 3 items
The following items were blocked because they don't meet the GitHub integrity level.
search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter:What is this? | From workflow: Bug Hunter
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.