Skip to content

Commit 4ed9ff1

Browse files
committed
fix: review fixes
1 parent 7fc18dc commit 4ed9ff1

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

  • api/v3/handlers/subscriptions/subscriptionaddons
  • openmeter/subscription/addon

api/v3/handlers/subscriptions/subscriptionaddons/get.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package subscriptionaddons
22

33
import (
44
"context"
5+
"errors"
56
"net/http"
67

78
apiv3 "github.com/openmeterio/openmeter/api/v3"
@@ -43,6 +44,10 @@ func (h *handler) GetSubscriptionAddon() GetSubscriptionAddonHandler {
4344
return GetSubscriptionAddonResponse{}, err
4445
}
4546

47+
if a == nil {
48+
return GetSubscriptionAddonResponse{}, models.NewGenericNotFoundError(errors.New("subscription addon not found"))
49+
}
50+
4651
return toAPISubscriptionAddon(*a)
4752
},
4853
commonhttp.JSONResponseEncoderWithStatus[GetSubscriptionAddonResponse](http.StatusOK),

openmeter/subscription/addon/service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ type GetSubscriptionAddonInput struct {
8585
func (i GetSubscriptionAddonInput) Validate() error {
8686
var errs []error
8787

88-
if err := i.NamespacedID.Validate(); err != nil {
89-
errs = append(errs, err)
88+
if i.NamespacedID.Namespace == "" {
89+
errs = append(errs, errors.New("namespace is required"))
9090
}
9191

9292
if i.ID == "" {
9393
if i.SubscriptionID == "" {
94-
errs = append(errs, errors.New("subscription id or key must be provided if assignment id is not provided"))
94+
errs = append(errs, errors.New("subscription id must be provided if assignment id is not provided"))
9595
} else if _, err := ulid.Parse(i.SubscriptionID); err != nil {
9696
errs = append(errs, errors.New("subscription id is not a valid ULID"))
9797
}

0 commit comments

Comments
 (0)