Repository navigation
fix(cli): remove --dry-run flag; --purchase alone executes real purchases - #1485
Conversation
|
@coderabbitai review |
📝 WalkthroughWalkthroughThe CLI purchase contract now treats dry-run as the default, with real purchases enabled through ChangesSingle-flag purchase contract
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
✅ Action performedReview finished.
|
…false) The --dry-run flag defaulted to true, so effectiveDryRun (!ActualPurchase || DryRun) stayed true even when --purchase was given -- meaning --purchase alone never executed real purchases, defeating the flag. Default --dry-run to false; the safe default is preserved because ActualPurchase defaults to false (a bare invocation is still dry-run). Passing --dry-run alongside --purchase still forces dry-run as an explicit safety override. Adds a regression test that fails on the prior true default and covers all four flag combinations.
c9c49d6 to
fcf50b2
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
…ases The `--purchase` flag never bought anything on its own because `--dry-run` defaulted to true and the guard was `!ActualPurchase || DryRun`, so `--purchase` gave `!true || true == true` (a dry run). Users had to pass `--purchase --dry-run=false` to actually buy. (Surfaced by CodeRabbit on #1364.) Rather than flip `--dry-run`'s default to false (which leaves a confusing flag named `--dry-run` that defaults off and only acts as a redundant "force dry-run even with --purchase" override), remove the flag entirely. `--purchase` is now the single purchase control: effectiveDryRun(cfg) = !cfg.ActualPurchase A bare run is always a dry run; `--purchase` is the one opt-in that moves money (still gated by the `--yes` / interactive confirmation prompt). This also unifies the two code paths: cloud-fetch and `--input-csv` mode now behave identically, matching what the CSV path already documented. Docs (purchase-safety.md, cli/README.md) are updated to the single-flag model with a History note explaining the removal. Tests replace the default-value guard with `TestDryRunFlagRemoved`, which fails if the flag is ever reintroduced.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/effective_dry_run_test.go (1)
5-30: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy liftTest the CLI and CSV boundaries, not only the helper.
This test constructs
Configdirectly, so it would pass even if--purchasestopped populatingActualPurchaseor the CSV handler bypassedeffectiveDryRun. Add focused command-binding and CSV-path tests with the purchase boundary mocked.Based on learnings, dry-run behavior must be verified consistently across CSV and non-CSV execution paths.
🤖 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/effective_dry_run_test.go` around lines 5 - 30, Extend TestEffectiveDryRun coverage beyond direct Config construction by testing CLI argument binding for --purchase and both CSV and non-CSV execution paths. Mock the purchase boundary, verify bare runs remain dry-run, and verify --purchase reaches real purchases consistently without the CSV handler bypassing effectiveDryRun.Source: Learnings
🤖 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 `@cmd/effective_dry_run_test.go`:
- Around line 5-30: Extend TestEffectiveDryRun coverage beyond direct Config
construction by testing CLI argument binding for --purchase and both CSV and
non-CSV execution paths. Mock the purchase boundary, verify bare runs remain
dry-run, and verify --purchase reaches real purchases consistently without the
CSV handler bypassing effectiveDryRun.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b18467a0-d3ac-46cd-a606-5b2b2b069339
📒 Files selected for processing (5)
cmd/effective_dry_run_test.gocmd/main.gocmd/multi_service.godocs/cli/README.mddocs/cli/purchase-safety.md
💤 Files with no reviewable changes (1)
- cmd/main.go
Ready for human mergeCommit CI: all 19 checks passing (Unit / Integration / E2E Tests, Lint Code, gosec, Trivy, Snyk, Security Scanning, Build Docker Image, AWS+Azure sanity dry-runs, all 3 Terraform validations, IAM/RBAC parity). No failures. CodeRabbit: clean. The earlier incremental pass was rate-limited (its walkthrough still described the prior default-flip approach), so a Not self-merging or self-approving; leaving for a human to merge. |
|
Tip For best results, initiate chat on the files or code changes.
|
…ases (#1485) * fix(cli): make --purchase execute real purchases (--dry-run defaults false) The --dry-run flag defaulted to true, so effectiveDryRun (!ActualPurchase || DryRun) stayed true even when --purchase was given -- meaning --purchase alone never executed real purchases, defeating the flag. Default --dry-run to false; the safe default is preserved because ActualPurchase defaults to false (a bare invocation is still dry-run). Passing --dry-run alongside --purchase still forces dry-run as an explicit safety override. Adds a regression test that fails on the prior true default and covers all four flag combinations. * fix(cli): remove --dry-run flag; --purchase alone executes real purchases The `--purchase` flag never bought anything on its own because `--dry-run` defaulted to true and the guard was `!ActualPurchase || DryRun`, so `--purchase` gave `!true || true == true` (a dry run). Users had to pass `--purchase --dry-run=false` to actually buy. (Surfaced by CodeRabbit on #1364.) Rather than flip `--dry-run`'s default to false (which leaves a confusing flag named `--dry-run` that defaults off and only acts as a redundant "force dry-run even with --purchase" override), remove the flag entirely. `--purchase` is now the single purchase control: effectiveDryRun(cfg) = !cfg.ActualPurchase A bare run is always a dry run; `--purchase` is the one opt-in that moves money (still gated by the `--yes` / interactive confirmation prompt). This also unifies the two code paths: cloud-fetch and `--input-csv` mode now behave identically, matching what the CSV path already documented. Docs (purchase-safety.md, cli/README.md) are updated to the single-flag model with a History note explaining the removal. Tests replace the default-value guard with `TestDryRunFlagRemoved`, which fails if the flag is ever reintroduced.
Problem
The
--purchaseflag never executed real purchases when used alone.--dry-rundefaulted totrue, and the guard is:So
--purchase(ActualPurchase=true) with the defaultDryRun=truegave!true || true == true— a dry run. Users had to pass--purchase --dry-run=falseto actually buy, which is unintuitive and defeats the flag. (Surfaced by CodeRabbit on #1364.)Fix (updated: remove the flag entirely)
The original version of this PR flipped
--dry-run's default tofalse. On review that was rejected as still confusing: a flag literally named--dry-runthat defaults off is a footgun, and its only remaining use would be a redundant "force dry-run even with--purchase" override that muddied the contract.Instead,
--dry-runis removed entirely.--purchaseis now the single purchase control:--purchase--yes/ interactive confirmation prompt)A bare run is always a dry run;
--purchaseis the one and only opt-in that moves money. This also unifies the two code paths — cloud-fetch mode and--input-csvmode now behave identically (isDryRun = !ActualPurchase), which is exactly what the CSV path was already documented to do.Docs
docs/cli/purchase-safety.mdanddocs/cli/README.mdare rewritten for the single-flag model, with a History note explaining why--dry-runwas removed. The stale--purchase --dry-run=falseexamples are corrected to--purchase.Tests
cmd/effective_dry_run_test.go:TestEffectiveDryRun— asserts the two-state contract (bare → dry-run,--purchase→ real).TestDryRunFlagRemoved— replaces the old default-value guard; fails if the--dry-runflag is ever reintroduced.go build ./cmd/...,go vet ./cmd/...clean;gocyclo -over 10clean;golangci-lint(CI-pinned v2.10.1) = 0 issues;go test ./cmd/passing.Summary by CodeRabbit
New Features
--purchaseexplicitly enables real purchases.--yesrequirement.Bug Fixes
--dry-runoption.Documentation