Skip to content

Commit 7822137

Browse files
committed
[usage] Don't pass '0001-01-01T00:15:00Z' timestamps through the CostCenter API when it should be undefined 🙃
1 parent 518b3b5 commit 7822137

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

components/usage/pkg/apiv1/usage.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,20 @@ func (s *UsageService) GetCostCenter(ctx context.Context, in *v1.GetCostCenterRe
190190
}
191191

192192
func dbCostCenterToAPI(c db.CostCenter) *v1.CostCenter {
193+
NextBillingTime := timestamppb.New(c.NextBillingTime.Time())
194+
if !c.NextBillingTime.IsSet() {
195+
NextBillingTime = nil
196+
}
197+
BillingCycleStart := timestamppb.New(c.BillingCycleStart.Time())
198+
if !c.BillingCycleStart.IsSet() {
199+
BillingCycleStart = nil
200+
}
193201
return &v1.CostCenter{
194202
AttributionId: string(c.ID),
195203
SpendingLimit: c.SpendingLimit,
196204
BillingStrategy: convertBillingStrategyToAPI(c.BillingStrategy),
197-
NextBillingTime: timestamppb.New(c.NextBillingTime.Time()),
198-
BillingCycleStart: timestamppb.New(c.BillingCycleStart.Time()),
205+
NextBillingTime: NextBillingTime,
206+
BillingCycleStart: BillingCycleStart,
199207
}
200208
}
201209

0 commit comments

Comments
 (0)