From bd9f6901076a1c596e6c2a1c4b4f68cb0fe1f1ac Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 22 Apr 2026 20:08:21 +0200 Subject: [PATCH] Optimizer: fix panic in prorate --- core/site_optimizer.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/site_optimizer.go b/core/site_optimizer.go index d8686c471..ac4a658ce 100644 --- a/core/site_optimizer.go +++ b/core/site_optimizer.go @@ -559,6 +559,11 @@ func profileSlotsFromNow(profile []float64) []float64 { // prorate adjusts the first slot's energy amount according to remaining duration func prorate[T constraints.Float](slots []T, firstSlotDuration time.Duration) []float32 { + // return empty slice instead of nil to make api happy + if len(slots) == 0 { + return []float32{} + } + res := slices.Clone(slots) res[0] = res[0] * T(firstSlotDuration) / T(tariff.SlotDuration) return lo.Map(res, func(f T, _ int) float32 {