-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BE-636-backwards-compatibility | Backwards compatibility support #582
Conversation
Adds backwards compatibility support for /pools endpoint allowing independent deployment of SQS
Quality Gate passedIssues Measures |
WalkthroughThe changes introduce a new method Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
pkg/api/v1beta1/pools/http.go (2)
Line range hint
14-29
: LGTM! Consider adding deprecation documentation.The deprecation notices and their replacements are clearly marked. However, it would be beneficial to document the deprecation timeline and migration guide for users.
Consider adding:
- When these parameters will be fully deprecated
- A migration guide in the API documentation
- Deprecation warnings in the API response headers
60-66
: Consider adding telemetry for legacy parameter usage.While the implementation correctly identifies legacy requests, adding telemetry would help monitor the usage of deprecated parameters and inform future deprecation decisions.
Consider adding metrics:
func (r *GetPoolsRequest) IsLegacy(c echo.Context) bool { + // Track usage of deprecated parameters + if c.QueryParam(queryIDs) != "" { + metrics.IncDeprecatedParameterUsage("pools_ids") + } + if c.QueryParam(queryMinLiquidityCap) != "" { + metrics.IncDeprecatedParameterUsage("pools_min_liquidity_cap") + } + if c.QueryParam(queryWithMarketIncentives) != "" { + metrics.IncDeprecatedParameterUsage("pools_with_market_incentives") + } return c.QueryParam(queryIDs) != "" || c.QueryParam(queryMinLiquidityCap) != "" || c.QueryParam(queryWithMarketIncentives) != "" }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
pkg/api/v1beta1/pools/http.go
(1 hunks)pools/delivery/http/pools_handler.go
(2 hunks)
🔇 Additional comments (2)
pools/delivery/http/pools_handler.go (2)
108-108
: LGTM! Clean integration of backwards compatibility check.
The change maintains the existing error handling while elegantly introducing the backwards compatibility check.
213-222
: 🛠️ Refactor suggestion
Consider improving type safety and response validation.
While the implementation achieves backwards compatibility, there are some concerns:
- Using
any
as return type reduces type safety - No validation of the response structure against API schema
Consider this alternative approach:
-func convertPoolsToResponse(c echo.Context, req *api.GetPoolsRequest, p []sqsdomain.PoolI, total uint64) any {
+func convertPoolsToResponse(c echo.Context, req *api.GetPoolsRequest, p []sqsdomain.PoolI, total uint64) (interface{}, error) {
pools := make([]PoolResponse, 0, len(p))
for _, pool := range p {
pools = append(pools, convertPoolToResponse(pool))
}
if req.IsLegacy(c) {
- return pools // backward compatibility
+ // Validate against legacy API schema
+ if err := validateLegacyResponse(pools); err != nil {
+ return nil, fmt.Errorf("invalid legacy response: %w", err)
+ }
+ return pools, nil
}
- return &GetPoolsResponse{
+ response := &GetPoolsResponse{
Data: pools,
Meta: v1beta1.NewPaginationResponse(req.Pagination, total),
}
+ // Validate against current API schema
+ if err := validateResponse(response); err != nil {
+ return nil, fmt.Errorf("invalid response: %w", err)
+ }
+ return response, nil
}
Let's verify the impact of this change on error handling:
Adds backwards compatibility support for /pools endpoint allowing independent deployment of SQS (cherry picked from commit 16e9207)
Adds backwards compatibility support for /pools endpoint allowing independent deployment of SQS
Summary by CodeRabbit
New Features
Bug Fixes
Refactor