Skip to content

Commit

Permalink
fix: metronome nil check before using (#1221)
Browse files Browse the repository at this point in the history
* fix: metronome nil check before using

* fix: nil check on accounts
  • Loading branch information
adilansari authored May 19, 2023
1 parent 23b62ce commit 8dccdf3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/services/v1/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func (b *billingService) getMetronomeId(ctx context.Context, namespaceId string)
log.Warn().Msgf("Could not find namespace, this must not happen with right authn/authz configured")
return uuid.Nil, errors.NotFound("Namespace %s not found", namespaceId)
}
if nsMeta.Accounts == nil {
nsMeta.Accounts = &metadata.AccountIntegrations{}
}

mIdStr, enabled := nsMeta.Accounts.GetMetronomeId()
if !enabled || len(mIdStr) == 0 {
Expand Down
4 changes: 4 additions & 0 deletions server/services/v1/billing/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ func (r *UsageReporter) pushStorage() error {
events := make([]*StorageEvent, 0, len(tenants))
for _, t := range tenants {
nsMeta := t.GetNamespace().Metadata()
if nsMeta.Accounts == nil {
nsMeta.Accounts = &metadata.AccountIntegrations{}
}

if id, enabled := nsMeta.Accounts.GetMetronomeId(); len(id) == 0 || !enabled {
// user doesn't have metronome integration; skip
continue
Expand Down

0 comments on commit 8dccdf3

Please sign in to comment.