Skip to content

Commit 3d572a3

Browse files
committed
fix: review fixes
1 parent 42be295 commit 3d572a3

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
@@ -49,13 +49,13 @@ type GetSubscriptionAddonInput struct {
4949
func (i GetSubscriptionAddonInput) Validate() error {
5050
var errs []error
5151

52-
if err := i.NamespacedID.Validate(); err != nil {
53-
errs = append(errs, err)
52+
if i.NamespacedID.Namespace == "" {
53+
errs = append(errs, errors.New("namespace is required"))
5454
}
5555

5656
if i.ID == "" {
5757
if i.SubscriptionID == "" {
58-
errs = append(errs, errors.New("subscription id or key must be provided if assignment id is not provided"))
58+
errs = append(errs, errors.New("subscription id must be provided if assignment id is not provided"))
5959
} else if _, err := ulid.Parse(i.SubscriptionID); err != nil {
6060
errs = append(errs, errors.New("subscription id is not a valid ULID"))
6161
}

0 commit comments

Comments
 (0)