Skip to content

Fix: empty parameter error code for vpc peering endpoint #3771

Merged
SnobbishFish40 merged 3 commits into
NVIDIA:mainfrom
SnobbishFish40:fix/vpcPeeringEmptyParameterErrorCode
Jul 21, 2026
Merged

Fix: empty parameter error code for vpc peering endpoint #3771
SnobbishFish40 merged 3 commits into
NVIDIA:mainfrom
SnobbishFish40:fix/vpcPeeringEmptyParameterErrorCode

Conversation

@SnobbishFish40

@SnobbishFish40 SnobbishFish40 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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:

  • siteId / isMultiTenant: read the value from the parsed query-param slice instead of the single-value accessor, so an absent param still means "no filter" but a present-but-empty value is now rejected with 400.
  • siteId: a malformed, non-UUID value (e.g. ?siteId=notauuid) now returns 400 instead of 500, consistent with how vpcId/peerTenantId already handle bad UUIDs.
  • Test: added a test case asserting a malformed siteId returns 400.

Related issues

#3770

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

@SnobbishFish40 SnobbishFish40 self-assigned this Jul 21, 2026
@SnobbishFish40
SnobbishFish40 requested a review from a team as a code owner July 21, 2026 10:47
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e26d938f-03a6-4678-9695-9c2798652702

📥 Commits

Reviewing files that changed from the base of the PR and between da03ad6 and dc34159.

📒 Files selected for processing (1)
  • rest-api/api/pkg/api/handler/vpcpeering_test.go

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for VPC peering query parameters.
    • Invalid or empty site IDs now return a clear 400 Bad Request response.
    • Empty or invalid multi-tenant filters are rejected with a 400 Bad Request response.

Walkthrough

The VPC peering handler consistently parses query parameters, returns 400 for invalid siteId values, parses isMultiTenant earlier, and adds validation tests for invalid and empty inputs.

Changes

VPC peering query validation

Layer / File(s) Summary
Query parsing and validation
rest-api/api/pkg/api/handler/vpcpeering.go, rest-api/api/pkg/api/handler/vpcpeering_test.go
The handler uses shared query parameters, validates invalid siteId values with 400 responses, parses isMultiTenant before relation validation, and tests invalid or empty query values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: correcting vpc peering query-parameter error handling.
Description check ✅ Passed The description accurately describes the query-parameter behavior fixes and the added test coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🔐 TruffleHog Secret Scan

No secrets or credentials found!

Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉

🔗 View scan details

🕐 Last updated: 2026-07-21 10:50:21 UTC | Commit: da03ad6

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
rest-api/api/pkg/api/handler/vpcpeering_test.go (1)

515-521: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression cases for present-but-empty parameters.

This test covers malformed siteId, but not the new siteId= and isMultiTenant= 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

📥 Commits

Reviewing files that changed from the base of the PR and between b20d9f4 and da03ad6.

📒 Files selected for processing (2)
  • rest-api/api/pkg/api/handler/vpcpeering.go
  • rest-api/api/pkg/api/handler/vpcpeering_test.go

@hwadekar-nv hwadekar-nv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this

@SnobbishFish40
SnobbishFish40 merged commit 4f01182 into NVIDIA:main Jul 21, 2026
118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Null valued parameters not handled consistently on VPC Peering endpoints

2 participants