Repository navigation
fix(aws/rds): refuse the 'SQL Server' engine spelling in the licensed-engine check - #431
Conversation
…-engine check lookupEngineName refused engines starting with oracle, sqlserver or sql-server, but the Cost Explorer spelling "SQL Server" (with a space) lowercases to "sql server", passes normalizeEngineName unchanged, and slipped past the refusal. It then failed later as "no offerings found" instead of the license-model reason. Add "sql server" to the licensed prefixes so it is refused before any API call. Closes LeanerCloud#302 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50. Or wait 29 minutes for your next included review. View limit details
Comment |
|
Independent adversarial review: CLEAN at
Still needed before merge: owner approval of the fork CI runs and green CI on this SHA, and the author marking the PR ready. Labels mirrored from the linked issue. CodeRabbit skipped this draft; CR skipped: quota/draft, so the merge comment will carry |
|
@cristim the Security Scanning job on this head failed on a network error, not a finding. govulncheck found 0 vulnerabilities affecting the code. The job then died while downloading a module: 🤖 Generated with Claude Code |
|
Merged |
|
Independent delta review verdict: CLEAN at
|
|
Merge gate record at
Squash-merging with |
Root cause
lookupEngineName(providers/aws/services/rds/client.go) refuses Oracle and SQL Server engines, because their reserved-offeringProductDescriptionincludes a license model ((li)/(byol)) that the recommendation doesn't provide. It only checked for the prefixesoracle,sqlserverandsql-server. Cost Explorer spells the engineSQL Server, with a space.normalizeEngineNamelowercases that tosql serverand returns it unchanged, since it only rejects the baresqlserver/sql-server. So it got past the refusal, went out toDescribeReservedDBInstancesOfferingsas theProductDescription, and failed later with a misleading "no offerings found".Fix
I moved the prefix list into
licensedEnginePrefixesand added"sql server". The check now lives in a smallisLicensedEnginehelper. Any engine starting withsql server(for exampleSQL ServerorSQL Server Enterprise) now gets the samelicense model is not known; refusing to guesserror, before any API call.normalizeEngineNameis unchanged.Closes #302
Verification (unit tests with mocked RDS client only)
These are unit tests with a mocked
RDSAPI(MockRDSClient). No real AWS calls were made.TestFindOfferingID_LicensedEnginesRefusedBeforeAPICallgains the casesSQL Server,sql serverandSQL Server Enterprise. Each one asserts alicense modelerror and thatDescribeReservedDBInstancesOfferingsis never called.SQL_Serversubtest fails. The mock panics withmock: I don't know what to return because the method call was unexpected ... DescribeReservedDBInstancesOfferings(...), and the log showsengine=sql serverreaching the offering lookup.providers/awswithAWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null. This machine's default AWS profile is invalid, so it is masked out; the tests themselves need no credentials.go build ./...: OKgo vet ./services/rds/: OKgo test -race -short ./services/rds/: okgo test -short ./...(whole AWS module): all okgolangci-lint run --allow-parallel-runners ./services/rds/...(v2.10.1): 0 issuesgocyclo -over 10 services/rds/client.go: silentgofmt -l services/rds/: cleanNot covered: a live Cost Explorer → RDS run against real AWS.
Interaction with #430 (fix/issue-303)
Draft PR #430 changes the same package (offering pagination in
client.go, and new tests appended at the end ofclient_test.go). To keep the two apart, this PR only toucheslookupEngineNameand the existingTestFindOfferingID_LicensedEnginesRefusedBeforeAPICallcase list. It does not touch the pagination code or the end of the test file.git merge-tree --write-tree HEAD <fork/fix/issue-303 = dbac61d>exits 0 with no conflicts.go test -short ./services/rds/passes on the merged tree. The two PRs should merge cleanly in either order.Out of scope
normalizeEngineNamestill passessql serverthrough instead of rejecting the bare family name as ambiguous, the way it does forsqlserver. SincelookupEngineNamenow refuses it, there is no behavior gap on the purchase path. I left it alone so the error stays the license-model one the issue asks for.client.gowas already over the repo's 500-line guideline before this change; it is now 757 lines.Maintainer: please mirror the issue's triage labels onto this PR:
triaged,priority/p3,severity/low,urgency/eventually,impact/few,effort/xs,type/bug.🤖 Generated with Claude Code