Repository navigation
fix(cli): keep CSV TOTAL normalized units in line with the per-row NU cells - #2250
Merged
Merged
Conversation
… cells buildTotalRow multiplied every row's Count by RDSInstanceNUFromType, while formatNormalizedUnitsOrBlank only renders NU for RDS rows. The lookup accepts any type with three dot-separated parts, so ElastiCache types like cache.r7g.large resolved a size NU and inflated the TOTAL above the sum of the visible column. Extract rowNormalizedUnits as the single per-row NU source (0 for non-RDS services) and use it for both the cell and the TOTAL. Closes LeanerCloud#2005 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 2
✨ Finishing Touches
Comment |
Member
Independent review verdict: CLEAN at ca55a3cReviewer: fresh Claude agent (Sonnet, high effort), not the author, cold brief. Coordinator: claude-cc-reviewer. Blocking findings: none. Per-row cells and TOTAL now agree:
Display only: TOTAL NU feeds no other code path. The CSV loader still skips the TOTAL row ( What was attacked and how:
Gate:
|
This was referenced Oct 17, 2026
cristim
marked this pull request as ready for review
October 18, 2026 00:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
buildTotalRow(cmd/multi_service_csv.go) addedCount × RDSInstanceNUFromType(ResourceType)for every row, whileformatNormalizedUnitsOrBlankonly renders NU forrds/relational-dbrows.RDSInstanceNUFromTypeaccepts any type with three or more dot-separated parts, so an ElastiCache type such ascache.r7g.largeresolves thelargeNU (4). In a mixed--all-servicesrun, those rows show a blank NU cell but still feed the TOTAL. The TOTAL NU then comes out larger than the sum of the column above it.Fix
I added
rowNormalizedUnits(rec) float64as the one place that computes a row's NU:Count × NU(size)for RDS rows and0for every other service.formatNormalizedUnitsOrBlankrenders that value (blank when it is 0, same as before), andbuildTotalRowsums it. The TOTAL is now built from the same values the cells show. Rendering of each row's NU cell is unchanged.Closes #2005
Verification
All of this is unit/fixture evidence: CSV rendered in memory from hand-built
PurchaseResultfixtures. No cloud APIs were called. I ran tests withAWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/nullbecause the default AWS profile on this machine is invalid. These tests don't touch AWS config.New tests in
cmd/multi_service_csv_test.go:TestBuildTotalRow_NUSkipsRowsWithBlankNUCell: mixes RDS (db.r6g.large ×5), relational-db (db.r6g.xlarge ×2), ElastiCache (cache.r7g.large ×3), OpenSearch and EC2 rows. It checks that the TOTAL NU equals the parsed sum of the visible NU cells (36).TestBuildTotalRow_NUBlankWhenNoRowHasNU: with only an ElastiCache row, the TOTAL NU cell stays blank and Count still sums.Fail before (on
origin/main1306c4d, test file only):Pass after:
Mutation probe: I removed the service gate from
rowNormalizedUnitsand both new tests failed again. I then restored it.Other checks run on the final tree:
go build -o /dev/null ./cmd,go vet ./...,gofmt -l cmd/: cleango test -short ./cmd/ -count=1: ok.go test -short -raceon the CSV tests: okgolangci-lint run --allow-parallel-runners ./cmd/...(v2.10.1): 0 issuesgocyclo -over 10 cmd/multi_service_csv.go: silent (buildTotalRow 5, rowNormalizedUnits 3, formatNormalizedUnitsOrBlank 2)bash scripts/gosec-hook.sh <changed files>(gosec v2.28.0): 0 issuesgit secrets --scan(awslabs 1.3.0,--register-aws) in a freshgit initcopy with an isolated HOME: clean.scripts/test-git-secrets-allowlist.sh: 44 PASS, 0 FAILNot covered: I did not run a real
--all-servicespurchase/report against an AWS account.Out of scope / notes
RDSInstanceNUFromType(cloud-commitments-go) still accepts non-db.types. I left it alone. The CLI now gates on service before calling it, which matches the issue's suggested fix.cmd/multi_service_csv.gowas already over the CLAUDE.md 500-line guideline (607 lines before this PR). This PR adds about 10 lines and doesn't split the file.Maintainer: please mirror the issue's triage labels onto this PR (I don't have label permissions on this repo):
triaged,priority/p2,severity/medium,urgency/this-quarter,impact/few,effort/xs,type/bug.🤖 Generated with Claude Code