Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TAG := $(shell git rev-list --tags --max-count=1)
VERSION := $(shell git describe --tags ${TAG})
.PHONY: build check fmt lint test test-race vet test-cover-html help install proto admin-app compose-up-dev
.DEFAULT_GOAL := build
PROTON_COMMIT := "12e40fbcd34fd437d61c9d92764cb8f387d088f1"
PROTON_COMMIT := "91eaffcdc8435ee129f9f93b43ad957c32efee62"

admin-app:
@echo " > generating admin build"
Expand Down
11 changes: 2 additions & 9 deletions internal/api/v1beta1connect/billing_product.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ func (h *ConnectHandler) CreateProduct(ctx context.Context, request *connect.Req
MaxQuantity: request.Msg.GetBody().GetBehaviorConfig().GetMaxQuantity(),
}
}
// only link a plan when one is given; an empty plan id would persist a junk
// [""] entry that later breaks plan lookup by id.
var planIDs []string
if planID := request.Msg.GetBody().GetPlanId(); planID != "" {
planIDs = []string{planID}
}
newProduct, err := h.productService.Create(ctx, product.Product{
PlanIDs: planIDs,
Name: request.Msg.GetBody().GetName(),
Title: request.Msg.GetBody().GetTitle(),
Description: request.Msg.GetBody().GetDescription(),
Expand All @@ -100,8 +93,8 @@ func (h *ConnectHandler) CreateProduct(ctx context.Context, request *connect.Req
Metadata: metaDataMap,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("CreateProduct.Create: product_name=%s product_title=%s plan_id=%s behavior=%s price_count=%d feature_count=%d: %w",
request.Msg.GetBody().GetName(), request.Msg.GetBody().GetTitle(), request.Msg.GetBody().GetPlanId(),
return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("CreateProduct.Create: product_name=%s product_title=%s behavior=%s price_count=%d feature_count=%d: %w",
request.Msg.GetBody().GetName(), request.Msg.GetBody().GetTitle(),
request.Msg.GetBody().GetBehavior(), len(productPrices), len(productFeatures), err))
}

Expand Down
6 changes: 2 additions & 4 deletions internal/api/v1beta1connect/billing_product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,13 @@ func TestConnectHandler_CreateProduct(t *testing.T) {
Name: "Test Product",
Title: "Test Product Title",
Description: "Test product description",
PlanId: "plan-1",
Behavior: product.BasicBehavior.String(),
},
}),
want: nil,
wantErr: true,
wantErrCode: connect.CodeInternal,
wantErrMsg: errors.New("CreateProduct.Create: product_name=Test Product product_title=Test Product Title plan_id=plan-1 behavior=basic price_count=0 feature_count=0: service error"),
wantErrMsg: errors.New("CreateProduct.Create: product_name=Test Product product_title=Test Product Title behavior=basic price_count=0 feature_count=0: service error"),
},
{
name: "should create product successfully with minimal data",
Expand Down Expand Up @@ -557,7 +556,6 @@ func TestConnectHandler_CreateProduct(t *testing.T) {
Name: "Basic Product",
Title: "Basic Product Title",
Description: "Basic product description",
PlanId: "plan-1",
Behavior: product.BasicBehavior.String(),
BehaviorConfig: &frontierv1beta1.Product_BehaviorConfig{
SeatLimit: 10,
Expand Down Expand Up @@ -605,7 +603,7 @@ func TestConnectHandler_CreateProduct(t *testing.T) {
want: nil,
wantErr: true,
wantErrCode: connect.CodeInternal,
wantErrMsg: errors.New("CreateProduct.Create: product_name= product_title= plan_id= behavior= price_count=0 feature_count=0: validation error"),
wantErrMsg: errors.New("CreateProduct.Create: product_name= product_title= behavior= price_count=0 feature_count=0: validation error"),
},
}

Expand Down
Loading
Loading