Report
When the Azure Event Hub trigger sets unprocessedEventThreshold to 0 (explicit string "0" in trigger metadata), KEDA’s typed config accepts it (the default 64 is only applied when the key is missing or empty, not when the value is "0"). During metric collection, getTotalLagRelatedToPartitionAmount divides the total unprocessed event count by that threshold with no guard, which causes an integer division by zero and a runtime panic in Go.
There was no validation at scaler construction time comparable to other lag-based scalers (e.g. Kafka’s lagThreshold validation).
Expected Behavior
Scaler creation or validation should fail fast with a clear error (for example that unprocessedEventThreshold must be a positive number), consistent with scalers such as Kafka that reject non-positive lag thresholds. Scaling should never panic because of this setting.
Actual Behavior
The Azure Event Hub scaler could be created successfully with unprocessedEventThreshold: "0". The first execution path that computed lag and called getTotalLagRelatedToPartitionAmount(..., threshold=0) could panic (divide by zero), which can disrupt metric collection / the operator or metrics path depending on where the panic propagates.
Steps to Reproduce the Problem
|
func getTotalLagRelatedToPartitionAmount(unprocessedEventsCount int64, partitionCount int64, threshold int64) int64 { |
|
if (unprocessedEventsCount / threshold) > partitionCount { |
|
return partitionCount * threshold |
|
} |
|
|
|
return unprocessedEventsCount |
|
} |
Logs from KEDA operator
KEDA Version
2.19.0
Kubernetes Version
None
Platform
None
Scaler Details
azure event hub scaler
Would you be open to contributing a fix?
Yes
Anything else?
I will follow up with a fix shortly
Report
When the Azure Event Hub trigger sets
unprocessedEventThresholdto 0 (explicit string "0" in trigger metadata), KEDA’s typed config accepts it (the default64is only applied when the key is missing or empty, not when the value is "0"). During metric collection,getTotalLagRelatedToPartitionAmountdivides the total unprocessed event count by that threshold with no guard, which causes an integer division by zero and a runtime panic in Go.There was no validation at scaler construction time comparable to other lag-based scalers (e.g. Kafka’s lagThreshold validation).
Expected Behavior
Scaler creation or validation should fail fast with a clear error (for example that
unprocessedEventThresholdmust be a positive number), consistent with scalers such as Kafka that reject non-positive lag thresholds. Scaling should never panic because of this setting.Actual Behavior
The Azure Event Hub scaler could be created successfully with
unprocessedEventThreshold: "0". The first execution path that computed lag and calledgetTotalLagRelatedToPartitionAmount(..., threshold=0)could panic (divide by zero), which can disrupt metric collection / the operator or metrics path depending on where the panic propagates.Steps to Reproduce the Problem
keda/pkg/scalers/azure_eventhub_scaler.go
Lines 262 to 268 in 44daf4f
Logs from KEDA operator
KEDA Version
2.19.0
Kubernetes Version
None
Platform
None
Scaler Details
azure event hub scaler
Would you be open to contributing a fix?
Yes
Anything else?
I will follow up with a fix shortly