fix(cli): reconstruct service Details from CSV Engine/Deployment columns (closes #572) - #601
Conversation
The --input-csv loader parsed only Service/Region/ResourceType/Count/etc. and never read the Engine or Deployment columns, leaving rec.Details nil. RDS findOfferingID requires a *DatabaseDetails (engine + Multi-AZ) to look up an RI offering, so every RDS row failed with "invalid service details for RDS" when purchasing from a CSV. parseCSVRecord now reconstructs Details from the Engine/Deployment columns, mirroring the writer (DatabaseDetails/CacheDetails/ComputeDetails) so a CSV the tool wrote round-trips losslessly. Guarded on a non-empty Engine so minimal CSVs and Savings Plans rows keep their previous nil-Details behavior. Also skip the trailing TOTAL summary row so feeding the tool its own output no longer parses TOTAL as a bogus recommendation with an unknown service. Multi-account purchasing stays intentionally out of scope: the Account column remains informational and purchases run centrally in the --profile account. Closes #572
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCSV loader now reconstructs typed ChangesCSV Details Reconstruction
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
What
Make
--input-csvpurchasing work for RDS by reconstructingrec.Detailsfrom the CSV'sEngineandDeploymentcolumns.Why
loadRecommendationsFromCSV→parseCSVRecordparsed onlyService, Region, ResourceType, Account, AccountName, Term, PaymentOption, Count, EstimatedSavings. It never readEngine/Deployment, sorec.Detailsstayednil. The RDS purchase path can't proceed without it:So every RDS row failed with
invalid service details for RDSunder--input-csv … --purchase, before any AWS call. This blocks the edit-the-CSV-then-purchase workflow (the tool has no in-flow exclusion flag).Change
parseCSVRecordreconstructsDetailsfrom theEngine/Deploymentcolumns, mirroring the writer (extractEngine/extractDeploymentemitDatabaseDetails/CacheDetails/ComputeDetails), so a CSV the tool wrote round-trips losslessly. Guarded on a non-emptyEngine, so minimal CSVs and Savings Plans rows keep their previous nil-Details behavior.Engineis stored in Cost Explorer format ("Aurora MySQL");findOfferingIDalready normalizes it.parseCSVRecordsskips the trailingTOTALsummary row, so feeding the tool its own output no longer parsesTOTALas a bogus recommendation ("Service client not yet implemented for TOTAL").Out of scope (by design)
Multi-account purchasing from a single CSV. Purchases run centrally in the
--profileaccount; theAccountcolumn stays informational. This is the intended behavior, not a gap.Testing
go build ./cmd/...,go vet ./cmd/clean.go test ./cmd/→ 720 pass.TestLoadRecommendationsFromCSV:*DatabaseDetails(Aurora MySQL/single-az, MySQL/multi-az),*CacheDetails(ElastiCache),*ComputeDetails(EC2 platform).Enginecolumn leavesDetailsnil (Savings Plans / minimal CSV).TOTALsummary row is skipped.--input-csv … --profile shift-prd, no--purchase): loads 22 recs / 85 instances cleanly and no longer emits the spurious "Processing TOTAL" block.Closes #572
Summary by CodeRabbit