Skip to content

chore: Switch from deprecated attributes for VPC Prefix create/update request to Site#423

Open
thossain-nv wants to merge 1 commit intomainfrom
chore/vpc-prefix-site-call
Open

chore: Switch from deprecated attributes for VPC Prefix create/update request to Site#423
thossain-nv wants to merge 1 commit intomainfrom
chore/vpc-prefix-site-call

Conversation

@thossain-nv
Copy link
Copy Markdown
Contributor

Description

VPC Prefix create and update API handlers are currently using attributes that have been deprecated in Core proto. This PR updates the requests to use newer attributes.

Type of Change

  • Chore - Modification or removal of existing functionality (chore:)

Services Affected

  • API - API models or endpoints updated

Related Issues (Optional)

None

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated

Additional Notes

None

… Site request

Signed-off-by: Tareque Hossain <thossain@nvidia.com>
@thossain-nv thossain-nv requested a review from a team as a code owner April 24, 2026 01:08
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation error messaging for VPC prefix updates to more accurately indicate which fields cannot be modified.

Walkthrough

This pull request refactors VPC prefix request handling to adopt nested Config and Metadata structures within Temporal workflow payloads, renames workflow ID prefixes from "vpcprefix-" to "vpc-prefix-", updates validation error messaging, and strengthens test coverage with more rigorous assertions on Temporal workflow invocations.

Changes

Cohort / File(s) Summary
Handler Payload Restructuring
api/pkg/api/handler/vpcprefix.go
Create and update handlers reorganize request fields: Prefix and Name move into Config.Prefix and Metadata.Name respectively. Workflow IDs updated to use "vpc-prefix-<action>-" prefix pattern instead of "vpcprefix-<action>-".
Test Assertions Enhancement
api/pkg/api/handler/vpcprefix_test.go
Test suite strengthened with stricter Temporal workflow interaction validation. Both create and update tests now track ExecuteWorkflow call counts, verify request structure and field mapping (Metadata.Name, Config.Prefix), and employ early-return patterns for error cases.
Validation Message Refinement
api/pkg/api/model/vpcprefix.go
VPC prefix update validation error key changed from "prefix" to "prefixLength" to more precisely indicate that prefix length modification is unsupported.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 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 references switching from deprecated attributes to Site, which aligns with the handler and model changes, but the specific structural migrations (nested Config/Metadata) are not captured.
Description check ✅ Passed The description accurately states that VPC Prefix create/update handlers are being updated from deprecated attributes to newer Site attributes, matching the actual changes across handlers and models.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/vpc-prefix-site-call

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

@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-04-24 01:09:12 UTC | Commit: fe90a12

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
api/pkg/api/handler/vpcprefix_test.go (1)

531-540: Assert the new workflow ID contract as well.

These checks validate the payload shape, but the PR also changes StartWorkflowOptions.ID to vpc-prefix-*. Without asserting the options argument, that behavioral change is still untested.

Also applies to: 1521-1529

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/pkg/api/handler/vpcprefix_test.go` around lines 531 - 540, The test
currently asserts the workflow payload but not the StartWorkflowOptions.ID
change; locate the ExecuteWorkflow call in tsc.Calls (the last call where Method
== "ExecuteWorkflow") and additionally extract the options argument (the
StartWorkflowOptions argument passed to ExecuteWorkflow, e.g., at the index
before the workflow/request arguments) and assert its ID equals the expected
"vpc-prefix-<id>" value derived from resp.Id (or resp.Name if your contract uses
Name); add the assertion alongside the existing checks for
cwssaws.VpcPrefixCreationRequest so the test verifies the new workflow ID
contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/pkg/api/handler/vpcprefix_test.go`:
- Line 1519: The assertion is comparing resp.Updated against the original
vpcprefix instead of the entity that was modified (vpcprefix2), so replace the
reference to vpcprefix with vpcprefix2 in the failing check: assert.NotEqual(t,
resp.Updated.String(), vpcprefix2.Updated.String()). Update the assertion in the
test that covers "success case when name is updated with the same value" to
compare resp.Updated to vpcprefix2.Updated (the updated entity) so the test
verifies the updated record’s timestamp actually changed.

In `@api/pkg/api/handler/vpcprefix.go`:
- Line 279: The workflow ID string was changed from the historically-stable
format to a new value, breaking Temporal deduplication; revert the
StartWorkflowOptions.ID construction to the original stable format (use the
exact prior prefix used for this workflow, e.g.
"vpcprefix-create-"+vpcPrefix.ID.String()) wherever the handler builds the ID
(refer to StartWorkflowOptions.ID and the code that concatenates
vpcPrefix.ID.String()), and ensure the same exact ID format is used consistently
in the other affected spot (the handler code that references the workflow ID at
the second location) so duplicate protection remains effective.

In `@api/pkg/api/model/vpcprefix.go`:
- Around line 98-101: The validation currently returns a hardcoded
"prefixLength" error when either vpur.IPBlockID or vpur.PrefixLength is set,
which misattributes failures; update the validation in the Validate method that
checks vpur.IPBlockID and vpur.PrefixLength to return the correct field key(s):
use "ipBlockId" when vpur.IPBlockID != nil, "prefixLength" when
vpur.PrefixLength != nil, and include both entries if both are non-nil (build a
validation.Errors map accordingly) instead of always returning "prefixLength".

---

Nitpick comments:
In `@api/pkg/api/handler/vpcprefix_test.go`:
- Around line 531-540: The test currently asserts the workflow payload but not
the StartWorkflowOptions.ID change; locate the ExecuteWorkflow call in tsc.Calls
(the last call where Method == "ExecuteWorkflow") and additionally extract the
options argument (the StartWorkflowOptions argument passed to ExecuteWorkflow,
e.g., at the index before the workflow/request arguments) and assert its ID
equals the expected "vpc-prefix-<id>" value derived from resp.Id (or resp.Name
if your contract uses Name); add the assertion alongside the existing checks for
cwssaws.VpcPrefixCreationRequest so the test verifies the new workflow ID
contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: dbf8f08b-5319-4b44-b08c-a4db4e4e6738

📥 Commits

Reviewing files that changed from the base of the PR and between ac8e21c and fe90a12.

📒 Files selected for processing (3)
  • api/pkg/api/handler/vpcprefix.go
  • api/pkg/api/handler/vpcprefix_test.go
  • api/pkg/api/model/vpcprefix.go

assert.Equal(t, 1, len(resp.StatusHistory))
assert.Equal(t, tc.expectedName, resp.Name)

assert.NotEqual(t, resp.Updated.String(), vpcprefix.Updated.String())
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.

⚠️ Potential issue | 🟡 Minor

Compare Updated against the entity under test.

Line 1519 always uses vpcprefix.Updated, but the "success case when name is updated with the same value" path updates vpcprefix2. That assertion can pass without proving the updated record’s timestamp moved.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/pkg/api/handler/vpcprefix_test.go` at line 1519, The assertion is
comparing resp.Updated against the original vpcprefix instead of the entity that
was modified (vpcprefix2), so replace the reference to vpcprefix with vpcprefix2
in the failing check: assert.NotEqual(t, resp.Updated.String(),
vpcprefix2.Updated.String()). Update the assertion in the test that covers
"success case when name is updated with the same value" to compare resp.Updated
to vpcprefix2.Updated (the updated entity) so the test verifies the updated
record’s timestamp actually changed.


workflowOptions := temporalClient.StartWorkflowOptions{
ID: "vpcprefix-create-" + vpcPrefix.ID.String(),
ID: "vpc-prefix-create-" + vpcPrefix.ID.String(),
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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Temporal workflow duplicate ID behavior: if one deployment starts a workflow with ID "vpcprefix-create-<uuid>" and a later retry starts "vpc-prefix-create-<uuid>", will Temporal treat them as distinct workflows and bypass duplicate-workflow protection?

💡 Result:

No, Temporal will treat "vpcprefix-create-<uuid>" and "vpc-prefix-create-<uuid>" as distinct workflow IDs because they differ in case (P vs p) and hyphen placement. Workflow ID uniqueness is enforced with exact string matching, which is case-sensitive. Duplicate protection (via WorkflowIdReusePolicy and WorkflowIdConflictPolicy) only applies to identical Workflow IDs within the same Namespace. Temporal guarantees that only one Open Workflow Execution per exact Workflow ID can exist at a time, regardless of policy. Policies like RejectDuplicate or default Fail (for conflicts) prevent starting if an identical ID is Open or (for reuse) Closed with certain statuses. Since these IDs are different strings, protection is bypassed, allowing both to run concurrently.

Citations:


Preserve workflow ID stability across deployments.

Changing StartWorkflowOptions.ID from vpcprefix-* to vpc-prefix-* breaks Temporal's duplicate workflow protection. Temporal uses exact string matching (case-sensitive) for workflow IDs; these distinct strings will bypass deduplication. During rolling deployments or retries across versions, an old pod can start a workflow with ID vpcprefix-create-<uuid> and a retry through a new pod starts vpc-prefix-create-<uuid>—Temporal treats these as separate workflows and executes the operation twice.

Maintain a stable workflow ID format across rollout boundaries, or implement explicit deduplication logic in the handler layer.

Affects lines 279 and 836.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/pkg/api/handler/vpcprefix.go` at line 279, The workflow ID string was
changed from the historically-stable format to a new value, breaking Temporal
deduplication; revert the StartWorkflowOptions.ID construction to the original
stable format (use the exact prior prefix used for this workflow, e.g.
"vpcprefix-create-"+vpcPrefix.ID.String()) wherever the handler builds the ID
(refer to StartWorkflowOptions.ID and the code that concatenates
vpcPrefix.ID.String()), and ensure the same exact ID format is used consistently
in the other affected spot (the handler code that references the workflow ID at
the second location) so duplicate protection remains effective.

Comment on lines 98 to 101
if vpur.IPBlockID != nil || vpur.PrefixLength != nil {
return validation.Errors{
"prefix": errors.New("update has not been supported yet, only name allowed"),
"prefixLength": errors.New("prefix length modification is not supported at this time"),
}
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.

🛠️ Refactor suggestion | 🟠 Major

Return the rejected field name accurately.

When only ipBlockId is present, this now reports a prefixLength validation error. That misattributes the failure and will point clients at the wrong field.

Proposed fix
 	if vpur.IPBlockID != nil || vpur.PrefixLength != nil {
-		return validation.Errors{
-			"prefixLength": errors.New("prefix length modification is not supported at this time"),
-		}
+		errs := validation.Errors{}
+		if vpur.IPBlockID != nil {
+			errs["ipBlockId"] = errors.New("IP block modification is not supported at this time")
+		}
+		if vpur.PrefixLength != nil {
+			errs["prefixLength"] = errors.New("prefix length modification is not supported at this time")
+		}
+		return errs
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if vpur.IPBlockID != nil || vpur.PrefixLength != nil {
return validation.Errors{
"prefix": errors.New("update has not been supported yet, only name allowed"),
"prefixLength": errors.New("prefix length modification is not supported at this time"),
}
if vpur.IPBlockID != nil || vpur.PrefixLength != nil {
errs := validation.Errors{}
if vpur.IPBlockID != nil {
errs["ipBlockId"] = errors.New("IP block modification is not supported at this time")
}
if vpur.PrefixLength != nil {
errs["prefixLength"] = errors.New("prefix length modification is not supported at this time")
}
return errs
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/pkg/api/model/vpcprefix.go` around lines 98 - 101, The validation
currently returns a hardcoded "prefixLength" error when either vpur.IPBlockID or
vpur.PrefixLength is set, which misattributes failures; update the validation in
the Validate method that checks vpur.IPBlockID and vpur.PrefixLength to return
the correct field key(s): use "ipBlockId" when vpur.IPBlockID != nil,
"prefixLength" when vpur.PrefixLength != nil, and include both entries if both
are non-nil (build a validation.Errors map accordingly) instead of always
returning "prefixLength".

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 24, 2026

Test Results

8 991 tests  ±0   8 991 ✅ ±0   7m 51s ⏱️ +7s
  148 suites ±0       0 💤 ±0 
   14 files   ±0       0 ❌ ±0 

Results for commit fe90a12. ± Comparison against base commit ac8e21c.

♻️ This comment has been updated with latest results.

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.

1 participant