Rename apiId to artifactId in subscription REST APIs#2709
Conversation
|
Warning Review limit reached
Next review available in: 44 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughSubscription creation, listing, generated models, response mapping, and OpenAPI documentation now use ChangesSubscription artifact identifier migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
platform-api/internal/handler/subscription_handler.go (1)
159-159: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winReturn early if the subscription list is empty.
When
len(list) == 0, the handler continues execution and issues three backend queries (GetArtifactMetadataMap,GetPlanNameMap, andSubsForUUIDs) passing empty slices. Returning early avoids these unnecessary allocations and database/service calls.♻️ Proposed refactor
if err != nil { var appErr *apperror.Error if errors.As(err, &appErr) { return err } return serviceError(err, fmt.Sprintf("failed to list subscriptions for artifact %s in org %s", artifactId, orgId)) } + + if len(list) == 0 { + httputil.WriteJSON(w, http.StatusOK, map[string]any{ + "list": []map[string]any{}, + "count": 0, + "pagination": map[string]any{ + "total": total, + "offset": offset, + "limit": limit, + }, + }) + return nil + } // Bulk fetch artifact handles and plan names to avoid N+1 queries artifactUUIDSet := make(map[string]struct{})🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@platform-api/internal/handler/subscription_handler.go` at line 159, Update the subscription handler to return immediately when the subscription list is empty, before the bulk-fetch section that calls GetArtifactMetadataMap, GetPlanNameMap, and SubsForUUIDs. Preserve the existing response behavior while ensuring those backend queries are skipped for an empty list.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@platform-api/internal/handler/subscription_handler.go`:
- Line 159: Update the subscription handler to return immediately when the
subscription list is empty, before the bulk-fetch section that calls
GetArtifactMetadataMap, GetPlanNameMap, and SubsForUUIDs. Preserve the existing
response behavior while ensuring those backend queries are skipped for an empty
list.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0088c4a6-0d3c-4ea7-8cd3-99ec6129a5d2
📒 Files selected for processing (3)
platform-api/api/generated.goplatform-api/internal/handler/subscription_handler.goplatform-api/resources/openapi.yaml
96a33d0
Purpose
Fix a naming inconsistency in the
/subscriptionsREST APIs.Approach
Previously in subscription related REST APIs, the request/response bodies had
apiIdfield. Since the subscriptions are not limited for RestApis, but also applicable for MCP proxies, this had to be changed toartifactId. No internal changes were needed since the artifact resolution was already kind-based.Samples
N/A