Repository navigation
fix(cmd): fail the run when recommendation fetching fails - #2192
Conversation
fetchRecommendationsForRegion logged provider errors and returned nil, and fetchAllRecs logged region-discovery failures and continued, so an expired session or denied Cost Explorer call read as "Nothing to purchase" with exit 0. Both now return the error and the run exits 1. Empty answers and incomplete-but-usable answers keep their current behaviour. Refs #2190 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Independent review (claude-opus-5-5) of c969c5f: APPROVE Error paths checked
Verification
Non-blocking findings
CI on c969c5f: all checks pass (Unit Tests, Integration Tests, CI Success among them); gosec and Trivy are skipped. |
Closes #2190
What
A recommendation fetch failure (expired SSO, denied Cost Explorer call, region discovery failure) used to be logged and turned into "No recommendations found" / "Nothing to purchase" with exit 0. It now aborts the run with exit 1 and the cause.
fetchRecommendationsForRegionreturns([]Recommendation, error); provider errors are wrapped witherrRecommendationFetch.fetchAllRecsreturns the region-discovery and per-region fetch errors instead ofcontinue/logging them.IncompleteRecommendationsErrorand Azure partial-subscription results (warn and keep the usable rows), and interrupt handling (ctx cancel is not reported as a failure).Tests
TestFetchAllRecs_ActiveContextProviderErrorStaysRecoverable(it pinned the old behaviour: a throttled region only lost that region) withTestFetchAllRecs_ProviderErrorFailsTheRun; addedTestFetchAllRecs_EmptyResultIsNotAnError.TestRecommendationCompletenessCommandharness used to expect exit 0 forapi-errorandfailed-type; it now expects exit 1, the cause in the output and no CSV.go vet ./cmdandgo test ./cmdpass (72s).make lintcould not run locally: golangci-lint panics on this toolchain (environmental); the pre-commit gocyclo, vet and gofmt hooks pass.Live dry run (read-only; no purchase flags)
Fake credentials, so Cost Explorer rejects the call.
cudly --services ec2 --regions us-east-1 --term 1 --payment no-upfront:before (main 8ddb891):
after:
Overlap
cli#2186 touches
cmd/audit_recurring_cost_test.go, go.mod/go.sum; cli#2145 touchescmd/multi_service_csv*.go. No shared files.🤖 Generated with Claude Code
Summary by CodeRabbit