Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds plan management functionality to enable users to view and update tenant pricing plans. The implementation includes API endpoints for retrieving pricing plans, tax rates, and managing tenant plan configurations.
- Added REST endpoints for pricing plan and tax rate retrieval
- Implemented tenant-specific plan information retrieval and updates
- Added proper authorization checks using existing billing access controls
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| main.go | Added four new route handlers for plan management endpoints |
| billing.go | Implemented core plan management functions with proper error handling and authorization |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
billing.go
Outdated
| if plansResp.JSON200 == nil { | ||
| var msg pricingapi.Error | ||
| if err := json.Unmarshal(plansResp.Body, &msg); err != nil { | ||
| c.Logger().Error("failed to get pricing plans: %v", err) |
There was a problem hiding this comment.
Missing format verb: should use Errorf instead of Error when including the error variable.
| c.Logger().Error("failed to get pricing plans: %v", err) | |
| c.Logger().Errorf("failed to get pricing plans: %v", err) |
billing.go
Outdated
| if taxRatesResp.JSON200 == nil { | ||
| var msg pricingapi.Error | ||
| if err := json.Unmarshal(taxRatesResp.Body, &msg); err != nil { | ||
| c.Logger().Error("failed to get tax rates: %v", err) |
There was a problem hiding this comment.
Missing format verb: should use Errorf instead of Error when including the error variable.
| c.Logger().Error("failed to get tax rates: %v", err) | |
| c.Logger().Errorf("failed to get tax rates: %v", err) |
billing.go
Outdated
| c.Logger().Error("failed to get pricing plans: %v", err) | ||
| return c.String(http.StatusInternalServerError, "internal server error") | ||
| } | ||
| c.Logger().Error("failed to get pricing plans: %v", msg) |
There was a problem hiding this comment.
Missing format verb: should use Errorf instead of Error when including the msg variable.
| c.Logger().Error("failed to get pricing plans: %v", msg) | |
| c.Logger().Errorf("failed to get pricing plans: %v", msg) |
billing.go
Outdated
| c.Logger().Error("failed to get tax rates: %v", err) | ||
| return c.String(http.StatusInternalServerError, "internal server error") | ||
| } | ||
| c.Logger().Error("failed to get tax rates: %v", msg) |
There was a problem hiding this comment.
Missing format verb: should use Errorf instead of Error when including the msg variable.
| c.Logger().Error("failed to get tax rates: %v", msg) | |
| c.Logger().Errorf("failed to get tax rates: %v", msg) |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| usingNextPlanFromInt := int(*usingNextPlanFrom) | ||
| updateTenantPlanParam.UsingNextPlanFrom = &usingNextPlanFromInt |
There was a problem hiding this comment.
Potential integer overflow when converting int64 to int. On 32-bit systems, this conversion could lose data if the value exceeds the int range. Consider adding validation or using int64 consistently throughout the API.
| usingNextPlanFromInt := int(*usingNextPlanFrom) | |
| updateTenantPlanParam.UsingNextPlanFrom = &usingNextPlanFromInt | |
| // Avoid unsafe conversion: assign int64 pointer directly | |
| updateTenantPlanParam.UsingNextPlanFrom = usingNextPlanFrom |
| c.Logger().Error("failed to get user info") | ||
| return c.String(http.StatusInternalServerError, "internal server error") | ||
| } | ||
|
|
||
| if len(userInfo.Tenants) == 0 { | ||
| c.Logger().Error("user does not belong to any tenant") |
There was a problem hiding this comment.
[nitpick] Inconsistent logging practices: these Error() calls don't follow the Errorf() pattern used elsewhere in the same file (lines 618, 625, 628, etc.). For consistency with the rest of the codebase and proper structured logging, these should also use Errorf() even without format arguments.
| c.Logger().Error("failed to get user info") | |
| return c.String(http.StatusInternalServerError, "internal server error") | |
| } | |
| if len(userInfo.Tenants) == 0 { | |
| c.Logger().Error("user does not belong to any tenant") | |
| c.Logger().Errorf("failed to get user info") | |
| return c.String(http.StatusInternalServerError, "internal server error") | |
| } | |
| if len(userInfo.Tenants) == 0 { | |
| c.Logger().Errorf("user does not belong to any tenant") |
| } | ||
|
|
||
| if len(userInfo.Tenants) == 0 { | ||
| c.Logger().Error("user does not belong to any tenant") |
There was a problem hiding this comment.
[nitpick] Inconsistent logging practices: these Error() calls don't follow the Errorf() pattern used elsewhere in the same file (lines 618, 625, 628, etc.). For consistency with the rest of the codebase and proper structured logging, these should also use Errorf() even without format arguments.
| c.Logger().Error("user does not belong to any tenant") | |
| c.Logger().Errorf("user does not belong to any tenant") |
| func getTaxRates(c echo.Context) error { | ||
| userInfo, ok := c.Get(string(ctxlib.UserInfoKey)).(*authapi.UserInfo) | ||
| if !ok { | ||
| c.Logger().Error("failed to get user info") |
There was a problem hiding this comment.
[nitpick] Inconsistent logging practices: these Error() calls don't follow the Errorf() pattern used elsewhere in the same file (lines 618, 625, 628, etc.). For consistency with the rest of the codebase and proper structured logging, these should also use Errorf() even without format arguments.
| c.Logger().Error("failed to get user info") | |
| c.Logger().Errorf("failed to get user info") |
| } | ||
|
|
||
| if len(userInfo.Tenants) == 0 { | ||
| c.Logger().Error("user does not belong to any tenant") |
There was a problem hiding this comment.
[nitpick] Inconsistent logging practices: these Error() calls don't follow the Errorf() pattern used elsewhere in the same file (lines 618, 625, 628, etc.). For consistency with the rest of the codebase and proper structured logging, these should also use Errorf() even without format arguments.
| c.Logger().Error("user does not belong to any tenant") | |
| c.Logger().Errorf("user does not belong to any tenant") |
|
|
||
| userInfo, ok := c.Get(string(ctxlib.UserInfoKey)).(*authapi.UserInfo) | ||
| if !ok { | ||
| c.Logger().Error("failed to get user info") |
There was a problem hiding this comment.
[nitpick] Inconsistent logging practices: these Error() calls don't follow the Errorf() pattern used elsewhere in the same file (lines 618, 625, 628, etc.). For consistency with the rest of the codebase and proper structured logging, these should also use Errorf() even without format arguments.
| c.Logger().Error("failed to get user info") | |
| c.Logger().Errorf("failed to get user info") |
|
|
||
| userInfo, ok := c.Get(string(ctxlib.UserInfoKey)).(*authapi.UserInfo) | ||
| if !ok { | ||
| c.Logger().Error("failed to get user info") |
There was a problem hiding this comment.
[nitpick] Inconsistent logging practices: these Error() calls don't follow the Errorf() pattern used elsewhere in the same file (lines 618, 625, 628, etc.). For consistency with the rest of the codebase and proper structured logging, these should also use Errorf() even without format arguments.
| c.Logger().Error("failed to get user info") | |
| c.Logger().Errorf("failed to get user info") |
No description provided.