Issues/handle errors#7
Conversation
|
Warning Review limit reached
More reviews will be available in 28 minutes and 45 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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR introduces error classification helpers to detect transient routing errors and resource-not-found conditions, applies idempotent delete patterns across ~20 CLI commands, and enhances instance command resilience with automatic retry and network IP fallback logic. It also refines API request models, normalizes command flags, and adds comprehensive test coverage. ChangesError handling, instance resilience, and idempotent deletes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 2
🧹 Nitpick comments (2)
internal/commands/vmbackup.go (1)
184-192: 💤 Low valueConsider using
printer.Fprintffor consistency with the established pattern.The success message on line 191 uses
fmt.Fprintf(os.Stdout, ...), but the established pattern (as shown in iso.go context) is to useprinter.Fprintf(...)for success messages.♻️ Proposed fix for consistency
return fmt.Errorf("vm-backup delete: %w", err) } - fmt.Fprintf(os.Stdout, "VM backup %q deleted.\n", slug) + printer.Fprintf("VM backup %q deleted.\n", slug) return nilNote: You'll need to capture the
printerreturn value frombuildClientAndPrinteron line 177.🤖 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 `@internal/commands/vmbackup.go` around lines 184 - 192, The success message currently uses fmt.Fprintf(os.Stdout...)—capture the printer returned by buildClientAndPrinter (the same way other commands do) and replace the fmt.Fprintf call with printer.Fprintf to print the success message; keep the existing svc.Delete error handling (including apierrors.IsResourceNotFound) unchanged and only swap the output call to use printer.Fprintf so it follows the established pattern.internal/commands/snapshot.go (1)
225-232: 💤 Low valueConsider using
printer.Fprintffor consistency with the established pattern.The success message on line 232 uses
fmt.Fprintf(os.Stdout, ...), but the established pattern (as shown in iso.go context) is to useprinter.Fprintf(...)for success messages and reserve directfmt.Fprintf(os.Stderr, ...)for the "already deleted" case.♻️ Proposed fix for consistency
return fmt.Errorf("snapshot delete: %w", err) } - fmt.Fprintf(os.Stdout, "Snapshot %q deleted.\n", slug) + printer.Fprintf("Snapshot %q deleted.\n", slug) return nil🤖 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 `@internal/commands/snapshot.go` around lines 225 - 232, Replace the direct stdout write used after svc.Delete with the package printer for consistency: where the code calls fmt.Fprintf(os.Stdout, "Snapshot %q deleted.\n", slug) (inside the Delete handling block after svc.Delete(ctx, slug)), change it to printer.Fprintf(out, "Snapshot %q deleted.\n", slug) or printer.Fprintf(cmd.OutOrStdout(), ...) depending on the surrounding code’s printer/out variable; ensure the printer/Out variable used elsewhere in this file (as in iso.go patterns) is referenced so you keep the established messaging convention.
🤖 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 `@internal/commands/dns.go`:
- Around line 383-386: The fmt.Fprintf call that logs a missing DNS record is
using the string-quote verb %q for the integer variable recordID; update the
format specifier to %d so the integer prints correctly (change the fmt.Fprintf
invocation referencing recordID in the DNS delete handler to use "%d" instead of
"%q"). Ensure you only modify the format string and keep the same arguments and
error handling (the call around apierrors.IsResourceNotFound(err) and recordID).
In `@internal/commands/instance.go`:
- Around line 268-274: Add a mutual-exclusivity check before the user-data
handling so that if both userData (the inline --user-data flag) and userDataFile
(the --user-data-file flag) are set the command returns an error rather than
silently overwriting; specifically, in the function that contains the shown
snippet (where variables userData and userDataFile are used) add a check like:
if userData != "" && userDataFile != "" { return fmt.Errorf("flags --user-data
and --user-data-file are mutually exclusive") } and keep the existing logic that
reads the file into userData only when userDataFile is set.
---
Nitpick comments:
In `@internal/commands/snapshot.go`:
- Around line 225-232: Replace the direct stdout write used after svc.Delete
with the package printer for consistency: where the code calls
fmt.Fprintf(os.Stdout, "Snapshot %q deleted.\n", slug) (inside the Delete
handling block after svc.Delete(ctx, slug)), change it to printer.Fprintf(out,
"Snapshot %q deleted.\n", slug) or printer.Fprintf(cmd.OutOrStdout(), ...)
depending on the surrounding code’s printer/out variable; ensure the printer/Out
variable used elsewhere in this file (as in iso.go patterns) is referenced so
you keep the established messaging convention.
In `@internal/commands/vmbackup.go`:
- Around line 184-192: The success message currently uses
fmt.Fprintf(os.Stdout...)—capture the printer returned by buildClientAndPrinter
(the same way other commands do) and replace the fmt.Fprintf call with
printer.Fprintf to print the success message; keep the existing svc.Delete error
handling (including apierrors.IsResourceNotFound) unchanged and only swap the
output call to use printer.Fprintf so it follows the established pattern.
🪄 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: 7aaa7c67-c5ba-4254-8ff5-c2cb2dffff62
📒 Files selected for processing (32)
internal/api/apierrors/errors.gointernal/api/apierrors/errors_test.gointernal/api/instance/instance.gointernal/api/sshkey/sshkey.gointernal/api/volume/volume.gointernal/commands/affinitygroup.gointernal/commands/autoscale.gointernal/commands/backup.gointernal/commands/commands_test.gointernal/commands/dns.gointernal/commands/egress.gointernal/commands/firewall.gointernal/commands/instance.gointernal/commands/ip.gointernal/commands/iso.gointernal/commands/kubernetes.gointernal/commands/loadbalancer.gointernal/commands/network.gointernal/commands/objectstorage.gointernal/commands/portforward.gointernal/commands/profile.gointernal/commands/project.gointernal/commands/snapshot.gointernal/commands/sshkey.gointernal/commands/support.gointernal/commands/template.gointernal/commands/vmbackup.gointernal/commands/vmsnapshot.gointernal/commands/volume.gointernal/commands/vpc.gointernal/commands/vpn.gotests/smoke/cases.sh
…g bug fixes and new features
Summary by CodeRabbit
Release Notes
New Features
--user-dataor--user-data-fileflags--projectand--regionoptions--sizeparameter for custom plansBug Fixes
Changes
-yshorthand from--yesflags on delete commands