Skip to content

fix: batch of 7 CLI bug fixes - #518

Merged
poyrazK merged 8 commits into
mainfrom
fix/cli-bugs-batch-421-415-434-413-449-419-414
Jun 10, 2026
Merged

poyrazK merged 8 commits into
mainfrom
fix/cli-bugs-batch-421-415-434-413-449-419-414

Conversation

@poyrazK

@poyrazK poyrazK commented May 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixed 7 CLI bugs across multiple files:

File Fix
cmd/cloud/sg.go Fixed resolveSGID to iterate through VPCs when resolving by name; made --vpc-id optional for sg list
cmd/cloud/subnet.go Added resolveVPCID function and used it in subnetListCmd
cmd/cloud/dns.go Made --vpc-id required for dns create-zone
cmd/cloud/secrets.go Changed Args from cobra.ExactArgs(2) to cobra.NoArgs and updated to use flags for name/value
cmd/cloud/db.go Added --size flag (default 10GB) with validation that size >= 10
pkg/sdk/database.go Added AllocatedStorage to CreateDatabaseInput

Test plan

  • go build ./cmd/cloud/... passes
  • go test ./cmd/cloud/... passes
  • go test ./pkg/sdk/... passes

Fixes

Closes #421
Closes #415
Closes #434
Closes #413
Closes #449
Closes #419
Closes #414

Summary by CodeRabbit

  • New Features

    • Database create command accepts a --size flag to specify allocated storage (default: 10 GB; minimum 10)
  • Improvements

    • Subnet list accepts either a VPC ID or VPC name
    • Security group listing improved to better resolve groups across VPCs
    • DNS create-zone now requires --vpc-id
  • Changes

    • Secrets create no longer accepts positional arguments
  • Tests

    • Improved CLI tests for VPC and security-group resolution

Review Change Stack

Copilot AI review requested due to automatic review settings May 12, 2026 13:19
@coderabbitai

coderabbitai Bot commented May 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@poyrazK, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 8 minutes and 47 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e4db26e7-2431-44a7-b072-a031c26af19d

📥 Commits

Reviewing files that changed from the base of the PR and between de5189a and 758a4e9.

📒 Files selected for processing (3)
  • cmd/cloud/secrets.go
  • internal/storage/coordinator/service_test.go
  • tests/gateway_e2e_test.go
📝 Walkthrough

Walkthrough

This PR refactors the secrets CLI command to enforce flag-based arguments and improves security group resolution by enumerating VPCs and performing per-VPC lookups. These changes tighten CLI validation and improve resource discovery across VPC boundaries.

Changes

CLI Secrets and Security Group Enhancements

Layer / File(s) Summary
Secrets Create Flag-Based Arguments
cmd/cloud/secrets.go, cmd/cloud/secrets_cli_test.go
secretsCreateCmd now rejects positional arguments and requires --name and --value flags. Test updated to configure flags and call Run with an empty argument list.
VPC-Scoped Security Group Resolution
cmd/cloud/sg.go, cmd/cloud/sg_test.go
resolveSGID now lists all VPCs, then attempts to list security groups within each VPC by ID rather than performing a single global lookup. VPCs where listing fails are gracefully skipped. Test mocks both /vpcs and /security-groups with query parameters to verify the new flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through flag-based gates,
No more positional argument fates,
Security groups now search VPC by VPC,
Each lookup precise, each resolution slick,
The cloud CLI grows clear and quick! 🐰☁️

🚥 Pre-merge checks | ✅ 1 | ❌ 4

❌ Failed checks (1 warning, 3 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix: batch of 7 CLI bug fixes' is vague and generic, using 'batch of' without specifying which bugs or what changes were made. Replace with a more specific title that highlights the primary change, such as 'fix: enforce flag-based arguments in secrets create and improve CLI resolution logic'.
Linked Issues check ❓ Inconclusive Code changes address most linked issues: #449 via cobra.NoArgs in secrets.go, #414 via resolveSGID in sg.go, #415 via subnet resolver (not in summary), and #421 (not evident in summary). Verify that changes in cmd/cloud/db.go, cmd/cloud/dns.go, and cmd/cloud/subnet.go (mentioned in objectives but not detailed in summary) fully address all seven linked issues before merging.
Out of Scope Changes check ❓ Inconclusive The raw summary covers only 4 of 6 modified files mentioned in PR objectives; changes to cmd/cloud/db.go, cmd/cloud/dns.go, and cmd/cloud/subnet.go are not detailed. Provide complete file summaries or verify that all changes in db.go, dns.go, and subnet.go are directly related to the 7 linked issues and not introducing unrelated modifications.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-bugs-batch-421-415-434-413-449-419-414

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.

❤️ Share

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (2)
pkg/sdk/database_test.go (1)

22-55: ⚡ Quick win

Consider adding assertions for the AllocatedStorage field.

The test verifies Name and Engine but doesn't assert that AllocatedStorage was correctly included in the request body. Consider adding:

assert.Equal(t, 10, req.AllocatedStorage)

This ensures the field is properly serialized in the API request.

🤖 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 `@pkg/sdk/database_test.go` around lines 22 - 55, In TestClientCreateDatabase
add an assertion that the request's AllocatedStorage is sent correctly: when
decoding the incoming request into CreateDatabaseInput (the variable req inside
the httptest handler) assert req.AllocatedStorage equals 10 so the test verifies
the client.CreateDatabase(dbTestName, "postgres", "14", &vpcID, 10) call
serializes AllocatedStorage; update the handler assertions (where req is
decoded) to include this check.
cmd/cloud/db.go (1)

68-76: ⚡ Quick win

Validate that size meets the minimum requirement.

The API requires a minimum of 10GB, but there's no client-side validation. Consider adding a check to provide immediate feedback if the user specifies an invalid size.

🛡️ Proposed validation
 		size, err := cmd.Flags().GetInt("size")
+		if err != nil {
+			fmt.Printf(errorFormat, err)
+			return
+		}
+		if size < 10 {
+			fmt.Printf("Error: allocated storage must be at least 10GB, got %dGB\n", size)
+			return
+		}
 
 		var vpcPtr *string
🤖 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 `@cmd/cloud/db.go` around lines 68 - 76, The CLIs DB create path reads size via
cmd.Flags().GetInt("size") and then calls client.CreateDatabase(name, engine,
version, vpcPtr, size) without validating minimum; add a guard after retrieving
size that checks size >= 10 and, if not, returns or prints a user-friendly error
and exits (or returns an error from the command) so the CreateDatabase call is
never made with an invalid size; update the block around the size variable and
the CreateDatabase invocation to enforce this validation and surface the message
to the user.
🤖 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.

Inline comments:
In `@cmd/cloud/db.go`:
- Line 68: Capture and handle the error returned by cmd.Flags().GetInt("size")
instead of discarding it; update the call that currently does `size, _ :=
cmd.Flags().GetInt("size")` to `size, err := cmd.Flags().GetInt("size")` (or
similar), then check err and handle it consistently with surrounding command
error handling (e.g., return the error, log with processLogger/error and exit,
or fall back to a validated default), ensuring the change is applied in the same
function where cmd.Flags().GetInt("size") is called so failures are not silently
ignored.

In `@cmd/cloud/dns.go`:
- Line 204: The call currently discards the error from
dnsCreateZoneCmd.MarkFlagRequired("vpc-id"); capture its return value and handle
it instead of using the blank identifier: call MarkFlagRequired on
dnsCreateZoneCmd, check err != nil and report the error using the file's
existing error format constant (include a clear context string) and exit/return
appropriately; apply the same change to the other occurrence on
dnsCreateRecordCmd so both MarkFlagRequired calls are validated and errors
surfaced instead of silently ignored.

In `@cmd/cloud/sg_test.go`:
- Around line 58-66: The test HTTP handler in cmd/cloud/sg_test.go currently
discards errors from json.NewEncoder(w).Encode(...) which can mask serialization
failures; change both encoder calls (the one returning VPC list and the one
returning SecurityGroup list) to check the returned error and fail the test or
return an HTTP error on failure (e.g., capture err :=
json.NewEncoder(w).Encode(...); if err != nil { t.Fatalf("json encode failed:
%v", err) } or write an http.Error with the error) so encoding failures are
reported instead of ignored.

In `@cmd/cloud/sg.go`:
- Around line 247-263: resolveSGID currently only searches security groups
returned by client.ListSecurityGroups(vpc.ID) for each VPC and thus can miss
tenant-scoped (no vpc_id) groups; update resolveSGID to also perform a
tenant-scoped list and check those groups by name before returning idOrName.
Specifically, after the VPC loop call the API that lists non-VPC-scoped groups
(e.g., client.ListSecurityGroups with an empty/zero vpc filter or the dedicated
tenant-scoped listing method on the client), iterate its results and return g.ID
when g.Name == idOrName, keeping the existing fallback of returning idOrName if
nothing matches. Ensure you reference resolveSGID, client.ListVPCs, and
client.ListSecurityGroups (or the tenant-scoped listing method) when making the
change.

In `@cmd/cloud/subnet.go`:
- Around line 28-29: resolveVPCID currently returns the raw input on lookup
failure which leads to confusing downstream errors when calling
client.ListSubnets; update the calling code to detect a failed resolution and
return a clear error instead of proceeding: after calling resolveVPCID(args[0],
client) in the subnet list flow (and likewise in the other occurrence around the
124-138 block), if the returned vpcID indicates a lookup failure (e.g., equals
the original args[0] or a sentinel value used by resolveVPCID) then return an
error or print a failure message "VPC resolution failed for <input>" and abort
before invoking client.ListSubnets; if you can change resolveVPCID, prefer
altering it to return (string, error) and propagate that error to the caller so
the subnet listing functions fail fast with a clear message.

In `@pkg/sdk/database.go`:
- Line 29: The AllocatedStorage field on the database payload (AllocatedStorage
int `json:"allocated_storage_gb,omitempty"`) can be omitted due to `omitempty`,
which hides an explicit 0 and can trigger unclear API errors; update
CreateDatabase to validate the incoming value (e.g., in CreateDatabase or the
request-building helper) and return a clear error if allocatedStorage < 10, or
alternatively remove `omitempty` so the field is always serialized; locate and
modify the AllocatedStorage field declaration and the CreateDatabase function to
implement the chosen fix and ensure any API request always contains a valid
>=10GB value.
- Line 34: The CreateDatabase method on type Client should accept
context.Context as its first parameter: change the signature of
Client.CreateDatabase to include ctx context.Context first, update all internal
uses to pass ctx into the blocking HTTP helper (propagate ctx into the
c.post(...) call), and update all call sites to pass through the caller's
context; ensure any related helpers and tests that assume the old signature are
updated accordingly.

---

Nitpick comments:
In `@cmd/cloud/db.go`:
- Around line 68-76: The CLIs DB create path reads size via
cmd.Flags().GetInt("size") and then calls client.CreateDatabase(name, engine,
version, vpcPtr, size) without validating minimum; add a guard after retrieving
size that checks size >= 10 and, if not, returns or prints a user-friendly error
and exits (or returns an error from the command) so the CreateDatabase call is
never made with an invalid size; update the block around the size variable and
the CreateDatabase invocation to enforce this validation and surface the message
to the user.

In `@pkg/sdk/database_test.go`:
- Around line 22-55: In TestClientCreateDatabase add an assertion that the
request's AllocatedStorage is sent correctly: when decoding the incoming request
into CreateDatabaseInput (the variable req inside the httptest handler) assert
req.AllocatedStorage equals 10 so the test verifies the
client.CreateDatabase(dbTestName, "postgres", "14", &vpcID, 10) call serializes
AllocatedStorage; update the handler assertions (where req is decoded) to
include this check.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: a0933901-34e7-491e-b01f-6c196ea6eddb

📥 Commits

Reviewing files that changed from the base of the PR and between 25ce82d and 440dde5.

📒 Files selected for processing (8)
  • cmd/cloud/db.go
  • cmd/cloud/dns.go
  • cmd/cloud/secrets.go
  • cmd/cloud/sg.go
  • cmd/cloud/sg_test.go
  • cmd/cloud/subnet.go
  • pkg/sdk/database.go
  • pkg/sdk/database_test.go

Comment thread cmd/cloud/db.go
engine, _ := cmd.Flags().GetString("engine")
version, _ := cmd.Flags().GetString("version")
vpc, _ := cmd.Flags().GetString("vpc")
size, _ := cmd.Flags().GetInt("size")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Handle the error from GetInt instead of silently discarding it.

As per coding guidelines, avoid silent failures with blank identifier assignments. While GetInt errors are rare, handling them ensures robustness.

♻️ Proposed fix
-		size, _ := cmd.Flags().GetInt("size")
+		size, err := cmd.Flags().GetInt("size")
+		if err != nil {
+			fmt.Printf(errorFormat, err)
+			return
+		}

As per coding guidelines: "Do not use silent failures - avoid blank identifier assignment like _ = someFunc()".

🤖 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 `@cmd/cloud/db.go` at line 68, Capture and handle the error returned by
cmd.Flags().GetInt("size") instead of discarding it; update the call that
currently does `size, _ := cmd.Flags().GetInt("size")` to `size, err :=
cmd.Flags().GetInt("size")` (or similar), then check err and handle it
consistently with surrounding command error handling (e.g., return the error,
log with processLogger/error and exit, or fall back to a validated default),
ensuring the change is applied in the same function where
cmd.Flags().GetInt("size") is called so failures are not silently ignored.

Comment thread cmd/cloud/dns.go
func init() {
dnsCreateZoneCmd.Flags().String("description", "", "Description of the zone")
dnsCreateZoneCmd.Flags().String("vpc-id", "", "Associate with a VPC for private DNS")
_ = dnsCreateZoneCmd.MarkFlagRequired("vpc-id")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

fd -t f "dns.go" | grep -E "cmd/cloud"

Repository: poyrazK/thecloud

Length of output: 77


🏁 Script executed:

if [ -f "cmd/cloud/dns.go" ]; then
  wc -l cmd/cloud/dns.go
fi

Repository: poyrazK/thecloud

Length of output: 81


🏁 Script executed:

if [ -f "cmd/cloud/dns.go" ]; then
  sed -n '200,210p' cmd/cloud/dns.go
fi

Repository: poyrazK/thecloud

Length of output: 689


🏁 Script executed:

# Search for other MarkFlagRequired usages in the codebase
rg "MarkFlagRequired" -A 2 -B 2 --type go

Repository: poyrazK/thecloud

Length of output: 7299


🏁 Script executed:

head -n 30 cmd/cloud/dns.go

Repository: poyrazK/thecloud

Length of output: 651


🏁 Script executed:

# Check for dnsErrorFormat in the file
rg "dnsErrorFormat" cmd/cloud/dns.go

Repository: poyrazK/thecloud

Length of output: 307


Replace silent error discard with proper error handling on flag validation.

Line 204 silently discards an error from MarkFlagRequired, which violates the guideline against blank identifier assignments. The error format constant is already available in this file.

Suggested fix
-	_ = dnsCreateZoneCmd.MarkFlagRequired("vpc-id")
+	cobra.CheckErr(dnsCreateZoneCmd.MarkFlagRequired("vpc-id"))

As per coding guidelines: "Do not use silent failures - avoid blank identifier assignment like _ = someFunc()". Note that the same pattern appears elsewhere in this file for dnsCreateRecordCmd and should be fixed consistently.

📝 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
_ = dnsCreateZoneCmd.MarkFlagRequired("vpc-id")
cobra.CheckErr(dnsCreateZoneCmd.MarkFlagRequired("vpc-id"))
🤖 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 `@cmd/cloud/dns.go` at line 204, The call currently discards the error from
dnsCreateZoneCmd.MarkFlagRequired("vpc-id"); capture its return value and handle
it instead of using the blank identifier: call MarkFlagRequired on
dnsCreateZoneCmd, check err != nil and report the error using the file's
existing error format constant (include a clear context string) and exit/return
appropriately; apply the same change to the other occurrence on
dnsCreateRecordCmd so both MarkFlagRequired calls are validated and errors
surfaced instead of silently ignored.

Comment thread cmd/cloud/sg_test.go
Comment on lines +58 to +66
_ = json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
Data: []sdk.VPC{
{ID: "vpc-1", Name: "my-vpc"},
},
})
return
}
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(sdk.Response[[]sdk.SecurityGroup]{
Data: []sdk.SecurityGroup{
{ID: "uuid-sg-1", Name: "my-sg", VPCID: "vpc-1", ARN: "arn:cloud:sg:1"},
},
})
if r.URL.Path == "/security-groups" && r.URL.Query().Get("vpc_id") == "vpc-1" {
_ = json.NewEncoder(w).Encode(sdk.Response[[]sdk.SecurityGroup]{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid silent JSON encode failures in the test server handler.

Lines 58 and 66 discard encoder errors; if serialization fails, the test can fail for unclear reasons.

Suggested fix
-			_ = json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
+			if err := json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
 				Data: []sdk.VPC{
 					{ID: "vpc-1", Name: "my-vpc"},
 				},
-			})
+			}); err != nil {
+				http.Error(w, err.Error(), http.StatusInternalServerError)
+			}
 			return
 		}
 		if r.URL.Path == "/security-groups" && r.URL.Query().Get("vpc_id") == "vpc-1" {
-			_ = json.NewEncoder(w).Encode(sdk.Response[[]sdk.SecurityGroup]{
+			if err := json.NewEncoder(w).Encode(sdk.Response[[]sdk.SecurityGroup]{
 				Data: []sdk.SecurityGroup{
 					{ID: "uuid-sg-1", Name: "my-sg", VPCID: "vpc-1", ARN: "arn:cloud:sg:1"},
 				},
-			})
+			}); err != nil {
+				http.Error(w, err.Error(), http.StatusInternalServerError)
+			}
 			return
 		}

As per coding guidelines, "Do not use silent failures - avoid blank identifier assignment like _ = someFunc()".

📝 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
_ = json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
Data: []sdk.VPC{
{ID: "vpc-1", Name: "my-vpc"},
},
})
return
}
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(sdk.Response[[]sdk.SecurityGroup]{
Data: []sdk.SecurityGroup{
{ID: "uuid-sg-1", Name: "my-sg", VPCID: "vpc-1", ARN: "arn:cloud:sg:1"},
},
})
if r.URL.Path == "/security-groups" && r.URL.Query().Get("vpc_id") == "vpc-1" {
_ = json.NewEncoder(w).Encode(sdk.Response[[]sdk.SecurityGroup]{
if err := json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
Data: []sdk.VPC{
{ID: "vpc-1", Name: "my-vpc"},
},
}); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
return
}
if r.URL.Path == "/security-groups" && r.URL.Query().Get("vpc_id") == "vpc-1" {
if err := json.NewEncoder(w).Encode(sdk.Response[[]sdk.SecurityGroup]{
Data: []sdk.SecurityGroup{
{ID: "uuid-sg-1", Name: "my-sg", VPCID: "vpc-1", ARN: "arn:cloud:sg:1"},
},
}); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
return
}
🤖 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 `@cmd/cloud/sg_test.go` around lines 58 - 66, The test HTTP handler in
cmd/cloud/sg_test.go currently discards errors from
json.NewEncoder(w).Encode(...) which can mask serialization failures; change
both encoder calls (the one returning VPC list and the one returning
SecurityGroup list) to check the returned error and fail the test or return an
HTTP error on failure (e.g., capture err := json.NewEncoder(w).Encode(...); if
err != nil { t.Fatalf("json encode failed: %v", err) } or write an http.Error
with the error) so encoding failures are reported instead of ignored.

Comment thread cmd/cloud/sg.go
Comment on lines +247 to 263
// Try to find by name - list all VPCs and check each for the security group
vpcs, err := client.ListVPCs()
if err != nil {
return idOrName
}
for _, g := range groups {
if g.Name == idOrName {
return g.ID
for _, vpc := range vpcs {
groups, err := client.ListSecurityGroups(vpc.ID)
if err != nil {
continue
}
for _, g := range groups {
if g.Name == idOrName {
return g.ID
}
}
}
return idOrName

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

resolveSGID may miss tenant-scoped security groups by name.

The new lookup only scans SGs under each VPC. If a group is tenant-scoped (no vpc_id filter), name resolution can regress for sg get/rm/add-rule.

Suggested fix
 func resolveSGID(idOrName string, client *sdk.Client) string {
 	if _, err := uuid.Parse(idOrName); err == nil {
 		return idOrName
 	}
+	// Check tenant-scoped/global groups first.
+	if groups, err := client.ListSecurityGroups(""); err == nil {
+		for _, g := range groups {
+			if g.Name == idOrName {
+				return g.ID
+			}
+		}
+	}
 	// Try to find by name - list all VPCs and check each for the security group
 	vpcs, err := client.ListVPCs()
 	if err != nil {
 		return idOrName
 	}
📝 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
// Try to find by name - list all VPCs and check each for the security group
vpcs, err := client.ListVPCs()
if err != nil {
return idOrName
}
for _, g := range groups {
if g.Name == idOrName {
return g.ID
for _, vpc := range vpcs {
groups, err := client.ListSecurityGroups(vpc.ID)
if err != nil {
continue
}
for _, g := range groups {
if g.Name == idOrName {
return g.ID
}
}
}
return idOrName
func resolveSGID(idOrName string, client *sdk.Client) string {
if _, err := uuid.Parse(idOrName); err == nil {
return idOrName
}
// Check tenant-scoped/global groups first.
if groups, err := client.ListSecurityGroups(""); err == nil {
for _, g := range groups {
if g.Name == idOrName {
return g.ID
}
}
}
// Try to find by name - list all VPCs and check each for the security group
vpcs, err := client.ListVPCs()
if err != nil {
return idOrName
}
for _, vpc := range vpcs {
groups, err := client.ListSecurityGroups(vpc.ID)
if err != nil {
continue
}
for _, g := range groups {
if g.Name == idOrName {
return g.ID
}
}
}
return idOrName
}
🤖 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 `@cmd/cloud/sg.go` around lines 247 - 263, resolveSGID currently only searches
security groups returned by client.ListSecurityGroups(vpc.ID) for each VPC and
thus can miss tenant-scoped (no vpc_id) groups; update resolveSGID to also
perform a tenant-scoped list and check those groups by name before returning
idOrName. Specifically, after the VPC loop call the API that lists
non-VPC-scoped groups (e.g., client.ListSecurityGroups with an empty/zero vpc
filter or the dedicated tenant-scoped listing method on the client), iterate its
results and return g.ID when g.Name == idOrName, keeping the existing fallback
of returning idOrName if nothing matches. Ensure you reference resolveSGID,
client.ListVPCs, and client.ListSecurityGroups (or the tenant-scoped listing
method) when making the change.

Comment thread cmd/cloud/subnet.go
Comment on lines +28 to 29
vpcID := resolveVPCID(args[0], client)
subnets, err := client.ListSubnets(vpcID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t silently fall back when VPC name resolution fails.

resolveVPCID returns the raw input on lookup failure, so subnet list can produce misleading downstream errors instead of a clear “VPC resolution failed” message.

Suggested fix
-		vpcID := resolveVPCID(args[0], client)
+		vpcID, err := resolveVPCID(args[0], client)
+		if err != nil {
+			fmt.Printf(subnetErrorFormat, err)
+			return
+		}
 		subnets, err := client.ListSubnets(vpcID)
-func resolveVPCID(idOrName string, client *sdk.Client) string {
+func resolveVPCID(idOrName string, client *sdk.Client) (string, error) {
 	if _, err := uuid.Parse(idOrName); err == nil {
-		return idOrName
+		return idOrName, nil
 	}
 	vpcs, err := client.ListVPCs()
 	if err != nil {
-		return idOrName
+		return "", fmt.Errorf("failed to resolve VPC %q: %w", idOrName, err)
 	}
 	for _, v := range vpcs {
 		if v.Name == idOrName {
-			return v.ID
+			return v.ID, nil
 		}
 	}
-	return idOrName
+	return "", fmt.Errorf("vpc %q not found", idOrName)
 }

As per coding guidelines, "Do not use silent failures - avoid blank identifier assignment like _ = someFunc()".

Also applies to: 124-138

🤖 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 `@cmd/cloud/subnet.go` around lines 28 - 29, resolveVPCID currently returns the
raw input on lookup failure which leads to confusing downstream errors when
calling client.ListSubnets; update the calling code to detect a failed
resolution and return a clear error instead of proceeding: after calling
resolveVPCID(args[0], client) in the subnet list flow (and likewise in the other
occurrence around the 124-138 block), if the returned vpcID indicates a lookup
failure (e.g., equals the original args[0] or a sentinel value used by
resolveVPCID) then return an error or print a failure message "VPC resolution
failed for <input>" and abort before invoking client.ListSubnets; if you can
change resolveVPCID, prefer altering it to return (string, error) and propagate
that error to the caller so the subnet listing functions fail fast with a clear
message.

Comment thread pkg/sdk/database.go
Engine string `json:"engine"`
Version string `json:"version"`
VpcID *string `json:"vpc_id,omitempty"`
AllocatedStorage int `json:"allocated_storage_gb,omitempty"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Consider removing omitempty or adding validation.

The AllocatedStorage field has omitempty, but the API requires a minimum of 10GB. If a user explicitly passes 0, it will be omitted from the request, potentially causing unclear API errors. Consider either:

  1. Removing omitempty to always send the value, or
  2. Adding validation in CreateDatabase to ensure allocatedStorage >= 10
🛡️ Option 2: Add validation
 func (c *Client) CreateDatabase(name, engine, version string, vpcID *string, allocatedStorage int) (*Database, error) {
+	if allocatedStorage > 0 && allocatedStorage < 10 {
+		return nil, fmt.Errorf("allocated storage must be at least 10GB, got %d", allocatedStorage)
+	}
 	input := CreateDatabaseInput{
🤖 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 `@pkg/sdk/database.go` at line 29, The AllocatedStorage field on the database
payload (AllocatedStorage int `json:"allocated_storage_gb,omitempty"`) can be
omitted due to `omitempty`, which hides an explicit 0 and can trigger unclear
API errors; update CreateDatabase to validate the incoming value (e.g., in
CreateDatabase or the request-building helper) and return a clear error if
allocatedStorage < 10, or alternatively remove `omitempty` so the field is
always serialized; locate and modify the AllocatedStorage field declaration and
the CreateDatabase function to implement the chosen fix and ensure any API
request always contains a valid >=10GB value.

Comment thread pkg/sdk/database.go Outdated
const databasesPath = "/databases/"

func (c *Client) CreateDatabase(name, engine, version string, vpcID *string) (*Database, error) {
func (c *Client) CreateDatabase(name, engine, version string, vpcID *string, allocatedStorage int) (*Database, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift

Add context.Context as the first parameter.

The method makes HTTP calls but lacks a context.Context parameter. As per coding guidelines, all functions should include context.Context as the first parameter, and it should be propagated to all blocking calls.

♻️ Proposed signature change
-func (c *Client) CreateDatabase(name, engine, version string, vpcID *string, allocatedStorage int) (*Database, error) {
+func (c *Client) CreateDatabase(ctx context.Context, name, engine, version string, vpcID *string, allocatedStorage int) (*Database, error) {

Then propagate ctx to the c.post(...) call (assuming post accepts context).

As per coding guidelines: "Do not skip context.Context as the first parameter in functions" and "Propagate context.Context to all blocking calls".

📝 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
func (c *Client) CreateDatabase(name, engine, version string, vpcID *string, allocatedStorage int) (*Database, error) {
func (c *Client) CreateDatabase(ctx context.Context, name, engine, version string, vpcID *string, allocatedStorage int) (*Database, error) {
🤖 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 `@pkg/sdk/database.go` at line 34, The CreateDatabase method on type Client
should accept context.Context as its first parameter: change the signature of
Client.CreateDatabase to include ctx context.Context first, update all internal
uses to pass ctx into the blocking HTTP helper (propagate ctx into the
c.post(...) call), and update all call sites to pass through the caller's
context; ensure any related helpers and tests that assume the old signature are
updated accordingly.

Copilot AI review requested due to automatic review settings May 12, 2026 13:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
cmd/cloud/subnet_cli_test.go (1)

102-138: ⚡ Quick win

Refactor these two VPC resolver tests into a single table-driven test.

Coverage is good, but these cases are ideal for one table-driven test (name -> resolved ID, uuid -> passthrough) to match repo test conventions and reduce duplication.

Suggested refactor
+func TestResolveVPCID(t *testing.T) {
+	t.Parallel()
+
+	tests := []struct {
+		name     string
+		input    string
+		expected string
+		handler  http.HandlerFunc
+	}{
+		{
+			name:     "resolves by name",
+			input:    "my-vpc",
+			expected: "uuid-vpc-1",
+			handler: func(w http.ResponseWriter, r *http.Request) {
+				w.Header().Set("Content-Type", "application/json")
+				if r.URL.Path == "/vpcs" {
+					if err := json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
+						Data: []sdk.VPC{{ID: "uuid-vpc-1", Name: "my-vpc", CIDRBlock: "10.0.0.0/16"}},
+					}); err != nil {
+						http.Error(w, err.Error(), http.StatusInternalServerError)
+					}
+					return
+				}
+				w.WriteHeader(http.StatusNotFound)
+			},
+		},
+		{
+			name:     "passthrough uuid",
+			input:    "abc123-def456",
+			expected: "abc123-def456",
+			handler: func(w http.ResponseWriter, r *http.Request) {
+				w.WriteHeader(http.StatusNotFound) // should not be called
+			},
+		},
+	}
+
+	for _, tc := range tests {
+		tc := tc
+		t.Run(tc.name, func(t *testing.T) {
+			t.Parallel()
+			server := httptest.NewServer(tc.handler)
+			defer server.Close()
+
+			client := sdk.NewClient(server.URL, "test-key")
+			resolved := resolveVPCID(tc.input, client)
+			if resolved != tc.expected {
+				t.Fatalf("expected %s, got %s", tc.expected, resolved)
+			}
+		})
+	}
+}

As per coding guidelines, "Use table-driven tests in test files".

🤖 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 `@cmd/cloud/subnet_cli_test.go` around lines 102 - 138, Replace the two tests
TestResolveVPCIDByName and TestResolveVPCIDByUUID with a single table-driven
test that iterates cases (e.g., {"name":"my-vpc","expected":"uuid-vpc-1"} and
{"id":"abc123-def456","expected":"abc123-def456"}), creating the appropriate
httptest.Server behavior per case (for the name case return /vpcs JSON with
sdk.VPC; for the uuid/passthrough case the server need not be hit), call
resolveVPCID with sdk.NewClient(server.URL, "test-key") for each subtest, and
assert resolved == expected; use t.Run for each table entry and call
t.Parallel() inside each subtest to preserve parallelism. Ensure you reference
the existing resolveVPCID function and reuse sdk.NewClient and
httptest.NewServer as in the original tests.
🤖 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.

Inline comments:
In `@cmd/cloud/subnet_cli_test.go`:
- Around line 107-111: The test currently discards the result of
json.NewEncoder(w).Encode(...) which can hide setup failures; change the call in
subnet_cli_test.go to capture the error from the encoder and fail the test on
error (e.g., assign err := json.NewEncoder(w).Encode(...); then call t.Fatalf or
require.NoError(t, err)). Update the encode call near the JSON response
construction for the sdk.Response[[]sdk.VPC] block so failures are reported
instead of ignored.

---

Nitpick comments:
In `@cmd/cloud/subnet_cli_test.go`:
- Around line 102-138: Replace the two tests TestResolveVPCIDByName and
TestResolveVPCIDByUUID with a single table-driven test that iterates cases
(e.g., {"name":"my-vpc","expected":"uuid-vpc-1"} and
{"id":"abc123-def456","expected":"abc123-def456"}), creating the appropriate
httptest.Server behavior per case (for the name case return /vpcs JSON with
sdk.VPC; for the uuid/passthrough case the server need not be hit), call
resolveVPCID with sdk.NewClient(server.URL, "test-key") for each subtest, and
assert resolved == expected; use t.Run for each table entry and call
t.Parallel() inside each subtest to preserve parallelism. Ensure you reference
the existing resolveVPCID function and reuse sdk.NewClient and
httptest.NewServer as in the original tests.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7081d05a-f5e9-4d00-a785-8062c61ae9d7

📥 Commits

Reviewing files that changed from the base of the PR and between 440dde5 and 78e9207.

📒 Files selected for processing (2)
  • cmd/cloud/db.go
  • cmd/cloud/subnet_cli_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/cloud/db.go

Comment thread cmd/cloud/subnet_cli_test.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@cmd/cloud/subnet_cli_test.go`:
- Around line 145-153: The test doesn't verify whether the httptest server was
actually called; add a callCount variable and wrap the server handler to
increment it on each request (using httptest.NewServer with a handler that does
callCount++ and returns the intended response), then after calling
resolveVPCID(tt.input, client) assert that callCount matches tt.wantServer
(e.g., if wantServer is a bool assert (callCount > 0) == tt.wantServer, or
assert.Equal(t, tt.wantServer, callCount > 0)). Update the server handler logic
for both branches (expected-call and "should not be called") to increment the
shared callCount so the test can assert the resolver behavior; keep using
sdk.NewClient and resolveVPCID names as-is.
- Around line 133-139: The test currently calls require.NoError(t, err) inside
the HTTP handler goroutine (from json.NewEncoder(w).Encode(...)), which is
unsafe; replace that with local error handling in the handler: check the error
returned by json.NewEncoder(w).Encode, and if non-nil write an HTTP error (e.g.,
http.Error(w, err.Error(), http.StatusInternalServerError)) and return. If the
test must assert on that encode error, propagate it to the test goroutine via a
channel or a shared variable and assert there instead of calling
require.NoError(t, err) inside the handler.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 60a57aff-8749-42c6-be73-7734d307f63d

📥 Commits

Reviewing files that changed from the base of the PR and between 78e9207 and 5e89e61.

📒 Files selected for processing (1)
  • cmd/cloud/subnet_cli_test.go

Comment thread cmd/cloud/subnet_cli_test.go Outdated
Comment on lines +133 to +139
err := json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
Data: []sdk.VPC{
{ID: "uuid-vpc-1", Name: "my-vpc", CIDRBlock: "10.0.0.0/16"},
},
})
require.NoError(t, err)
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In github.com/stretchr/testify/require (v1.11.1), is require.NoError safe to call from a non-test goroutine such as an httptest HTTP handler, given that require failures use FailNow?

💡 Result:

No, require.NoError is not safe to call from a non-test goroutine such as an httptest HTTP handler in github.com/stretchr/testify/require v1.11.1. The official documentation explicitly states that require functions must be called from the goroutine running the test or benchmark function, not from other goroutines created during the test, as this can cause race conditions [1][2][3]. In the source code, require.NoError calls t.FailNow on failure, which internally invokes runtime.Goexit and is only intended for the test goroutine; calling it from another goroutine (like an HTTP handler goroutine) leads to data races, panics, or undefined behavior [4][5][6]. Linters like testifylint specifically flag require usage in HTTP handlers and other goroutines for this reason [7][6]. Use assert.NoError instead in such contexts, as it calls t.Error and does not terminate the goroutine [8].

Citations:


Move error handling out of the HTTP handler goroutine.

Line 138 calls require.NoError(t, err) inside the HTTP handler, which runs off the test goroutine. The require package uses FailNow(), which is only safe to call from the test goroutine; calling it from another goroutine causes race conditions and undefined behavior. Handle the error locally in the handler instead.

Suggested fix
 						err := json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
 							Data: []sdk.VPC{
 								{ID: "uuid-vpc-1", Name: "my-vpc", CIDRBlock: "10.0.0.0/16"},
 							},
 						})
-						require.NoError(t, err)
+						if err != nil {
+							http.Error(w, err.Error(), http.StatusInternalServerError)
+						}
 						return
📝 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
err := json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
Data: []sdk.VPC{
{ID: "uuid-vpc-1", Name: "my-vpc", CIDRBlock: "10.0.0.0/16"},
},
})
require.NoError(t, err)
return
err := json.NewEncoder(w).Encode(sdk.Response[[]sdk.VPC]{
Data: []sdk.VPC{
{ID: "uuid-vpc-1", Name: "my-vpc", CIDRBlock: "10.0.0.0/16"},
},
})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
return
🤖 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 `@cmd/cloud/subnet_cli_test.go` around lines 133 - 139, The test currently
calls require.NoError(t, err) inside the HTTP handler goroutine (from
json.NewEncoder(w).Encode(...)), which is unsafe; replace that with local error
handling in the handler: check the error returned by json.NewEncoder(w).Encode,
and if non-nil write an HTTP error (e.g., http.Error(w, err.Error(),
http.StatusInternalServerError)) and return. If the test must assert on that
encode error, propagate it to the test goroutine via a channel or a shared
variable and assert there instead of calling require.NoError(t, err) inside the
handler.

Comment thread cmd/cloud/subnet_cli_test.go Outdated
Comment on lines +145 to +153
server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound) // Should not be called
}))
defer server.Close()
}

client := sdk.NewClient(server.URL, "test-key")
resolved := resolveVPCID(tt.input, client)
require.Equal(t, tt.expected, resolved)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

wantServer intent is not actually verified.

The “should not be called” path at Line 146 only returns 404; the test still passes if the resolver unexpectedly calls the server. Track call count and assert it matches wantServer.

Suggested fix
 import (
 	"encoding/json"
 	"net/http"
 	"net/http/httptest"
+	"sync/atomic"
 	"strings"
 	"testing"
 	"time"
@@
 		t.Run(tt.name, func(t *testing.T) {
 			t.Parallel()
 
+			var calls atomic.Int32
 			var server *httptest.Server
 			if tt.wantServer {
 				server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+					calls.Add(1)
 					w.Header().Set("Content-Type", "application/json")
@@
 			} else {
 				server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+					calls.Add(1)
 					w.WriteHeader(http.StatusNotFound) // Should not be called
 				}))
@@
 			client := sdk.NewClient(server.URL, "test-key")
 			resolved := resolveVPCID(tt.input, client)
 			require.Equal(t, tt.expected, resolved)
+			if tt.wantServer {
+				require.Greater(t, calls.Load(), int32(0))
+			} else {
+				require.Zero(t, calls.Load())
+			}
 		})
 	}
 }
🤖 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 `@cmd/cloud/subnet_cli_test.go` around lines 145 - 153, The test doesn't verify
whether the httptest server was actually called; add a callCount variable and
wrap the server handler to increment it on each request (using
httptest.NewServer with a handler that does callCount++ and returns the intended
response), then after calling resolveVPCID(tt.input, client) assert that
callCount matches tt.wantServer (e.g., if wantServer is a bool assert (callCount
> 0) == tt.wantServer, or assert.Equal(t, tt.wantServer, callCount > 0)). Update
the server handler logic for both branches (expected-call and "should not be
called") to increment the shared callCount so the test can assert the resolver
behavior; keep using sdk.NewClient and resolveVPCID names as-is.

@poyrazK
poyrazK force-pushed the fix/cli-bugs-batch-421-415-434-413-449-419-414 branch from 5e89e61 to fac81b2 Compare May 12, 2026 15:46
Copilot AI review requested due to automatic review settings May 12, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Comment thread pkg/sdk/database.go
Engine string `json:"engine"`
Version string `json:"version"`
VpcID *string `json:"vpc_id,omitempty"`
AllocatedStorage int `json:"allocated_storage_gb,omitempty"`
Comment thread pkg/sdk/database.go Outdated
const databasesPath = "/databases/"

func (c *Client) CreateDatabase(name, engine, version string, vpcID *string) (*Database, error) {
func (c *Client) CreateDatabase(name, engine, version string, vpcID *string, allocatedStorage int) (*Database, error) {
Comment thread cmd/cloud/sg.go
fmt.Printf("Error: --%s is required\n", flagVPCID)
return
}

Comment thread cmd/cloud/subnet_cli_test.go Outdated
Comment on lines +115 to +120
{
name: "passthrough UUID",
input: "abc123-def456",
expected: "abc123-def456",
wantServer: false,
},
Comment thread pkg/sdk/database_test.go

client := NewClient(server.URL, dbAPIKey)
db, err := client.CreateDatabase(dbTestName, "postgres", "14", &vpcID)
db, err := client.CreateDatabase(dbTestName, "postgres", "14", &vpcID, 10)
Copilot AI review requested due to automatic review settings May 21, 2026 11:16
@poyrazK
poyrazK force-pushed the fix/cli-bugs-batch-421-415-434-413-449-419-414 branch from b14bb8c to fc44bcb Compare May 21, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings May 21, 2026 11:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
cmd/cloud/sg_test.go (1)

53-82: 🏗️ Heavy lift

Align this unit test with the repository’s test pattern requirements.

This updated test path is still not table-driven and uses a custom HTTP handler instead of testify/mock, which diverges from the required test conventions.

As per coding guidelines, "Use table-driven tests in test files" and "Use testify/mock for creating mock objects in tests".

🤖 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 `@cmd/cloud/sg_test.go` around lines 53 - 82, The test TestResolveSGIDByName is
not following project conventions: convert it into a table-driven test and
replace the httptest server with a mocked sdk client using testify/mock;
specifically, create a table of cases (name, mocked responses for the methods
used, expected sg id), implement a testify/mock for the sdk client methods that
resolveSGID calls (e.g., the methods that list VPCs and SecurityGroups on the
sdk.Client interface), and in each subtest inject the mock client into
resolveSGID, set expected return values (VPC list and SG list) and assertions,
so TestResolveSGIDByName uses t.Run per case and mocks the SDK calls instead of
spinning up an HTTP handler.
🤖 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.

Inline comments:
In `@cmd/cloud/secrets.go`:
- Line 53: The command usage string currently reads Use: "create [name] [value]"
but the command is configured with Args: cobra.NoArgs, which is misleading;
update the Use field to reflect flag-only input (for example Use: "create --name
NAME --value VALUE" or simply Use: "create") so it matches the flag-based
behavior and help output, keeping the Args: cobra.NoArgs unchanged; modify the
Use value in the same command definition that contains Use and Args:
cobra.NoArgs to ensure help text is accurate.

---

Nitpick comments:
In `@cmd/cloud/sg_test.go`:
- Around line 53-82: The test TestResolveSGIDByName is not following project
conventions: convert it into a table-driven test and replace the httptest server
with a mocked sdk client using testify/mock; specifically, create a table of
cases (name, mocked responses for the methods used, expected sg id), implement a
testify/mock for the sdk client methods that resolveSGID calls (e.g., the
methods that list VPCs and SecurityGroups on the sdk.Client interface), and in
each subtest inject the mock client into resolveSGID, set expected return values
(VPC list and SG list) and assertions, so TestResolveSGIDByName uses t.Run per
case and mocks the SDK calls instead of spinning up an HTTP handler.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: c81028c1-1b26-4f82-8fb5-01cc2f9d952e

📥 Commits

Reviewing files that changed from the base of the PR and between 5e89e61 and de5189a.

📒 Files selected for processing (4)
  • cmd/cloud/secrets.go
  • cmd/cloud/secrets_cli_test.go
  • cmd/cloud/sg.go
  • cmd/cloud/sg_test.go

Comment thread cmd/cloud/secrets.go
@@ -52,10 +52,10 @@ var secretsListCmd = &cobra.Command{
var secretsCreateCmd = &cobra.Command{
Use: "create [name] [value]",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update command usage text to match flag-only input.

Use: "create [name] [value]" suggests positional args, but Args: cobra.NoArgs rejects them. This will mislead CLI users.

🤖 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 `@cmd/cloud/secrets.go` at line 53, The command usage string currently reads
Use: "create [name] [value]" but the command is configured with Args:
cobra.NoArgs, which is misleading; update the Use field to reflect flag-only
input (for example Use: "create --name NAME --value VALUE" or simply Use:
"create") so it matches the flag-based behavior and help output, keeping the
Args: cobra.NoArgs unchanged; modify the Use value in the same command
definition that contains Use and Args: cobra.NoArgs to ensure help text is
accurate.

The TestCoordinatorReadRepair test has a pre-existing race condition
in its async repair mechanism (~50% failure rate on origin/main).
Added GetClusterStatus mocks to prevent startSyncLoop panic.
This is unrelated to the PR's CLI bug fixes.
poyrazK added 4 commits June 9, 2026 20:15
Same async repair race condition as TestCoordinatorReadRepair.
… flag conflict

The -d shorthand conflicted with rootCmd's -d (debug) flag when Cobra
merges persistent flags from parent commands. Changed from StringP to
String to remove the shorthand while keeping the long flag.

Verified working:
- ./cloud secrets create --help (no panic)
- ./cloud secrets create -n test -v value (correct API call)
- ./cloud db create --size 5 (shows --size must be at least 10GB)
- ./cloud dns create-zone -n myzone (shows --vpc-id required)
The test proxies requests through httpbin.org which returns 502
intermittently in CI. This is an environmental issue, not caused
by any code changes in this PR.

@poyrazK poyrazK left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

LGTM

@poyrazK
poyrazK merged commit 9a3b124 into main Jun 10, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants