Fix: empty parameter error code for vpc peering endpoint #3771
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughThe VPC peering handler consistently parses query parameters, returns 400 for invalid ChangesVPC peering query validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🔐 TruffleHog Secret Scan✅ No secrets or credentials found! Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉 🕐 Last updated: 2026-07-21 10:50:21 UTC | Commit: da03ad6 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rest-api/api/pkg/api/handler/vpcpeering_test.go (1)
515-521: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression cases for present-but-empty parameters.
This test covers malformed
siteId, but not the newsiteId=andisMultiTenant=behavior. Add both cases with expected HTTP 400 while retaining the existing omitted-parameter success coverage.Suggested test cases
+ { + name: "error when siteId is empty", + reqOrgName: tnOrg1, + queryString: "siteId=", + user: tnu1, + expectedStatus: http.StatusBadRequest, + }, + { + name: "error when isMultiTenant is empty", + reqOrgName: tnOrg1, + queryString: "isMultiTenant=", + user: tnu1, + expectedStatus: http.StatusBadRequest, + },🤖 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 `@rest-api/api/pkg/api/handler/vpcpeering_test.go` around lines 515 - 521, Add regression cases alongside the existing invalid siteId case in the VPC peering handler tests for present-but-empty siteId and isMultiTenant query parameters, each expecting http.StatusBadRequest. Retain the existing omitted-parameter success coverage and use the same test table structure and symbols.
🤖 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 `@rest-api/api/pkg/api/handler/vpcpeering_test.go`:
- Around line 515-521: Add regression cases alongside the existing invalid
siteId case in the VPC peering handler tests for present-but-empty siteId and
isMultiTenant query parameters, each expecting http.StatusBadRequest. Retain the
existing omitted-parameter success coverage and use the same test table
structure and symbols.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: ff290370-cb5f-4405-8712-693ade6e8c33
📒 Files selected for processing (2)
rest-api/api/pkg/api/handler/vpcpeering.gorest-api/api/pkg/api/handler/vpcpeering_test.go
hwadekar-nv
left a comment
There was a problem hiding this comment.
Thank you for fixing this
Description
GET /v2/org/{org}/forge/vpc-peering handled empty filter values inconsistently. The newer filters (status, vpcId, peerTenantId) rejected a present-but-blank value with 400, but the older siteId and isMultiTenant silently ignored a blank value and returned an unfiltered 200.
These changes make all five filters behave the same way.
Changes:
Related issues
#3770
Type of Change
Breaking Changes
Testing