Repository navigation
fix(aws/rds): refuse explicitly when the offering page cap hides uniqueness - #430
Conversation
…ueness Since LeanerCloud#300 the RDS offering lookup walks every page so a second distinct exact match fails loud, but the walk is still bounded by maxOfferingPages. An exact match seen before the cap was then reported only as a generic "pagination cap reached" error. Make that a documented refuse-only outcome: the cap stays at 5 pages (500 offerings, far above any realistic result for a request filtered on class, engine, multi-AZ, duration and payment option), and when the cap is hit after a match the error names the matched offering and states it cannot be proven unique, so nothing is purchased. Tests pin the refusal (match on the first and on the last allowed page with more pages remaining) and the boundary where the last allowed page ends the walk. Closes LeanerCloud#303 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 48 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 |
|
Merge gate record at
Squash-merging with |
Root cause
Since #300 (for #288),
paginateRDSOfferingsinproviders/aws/services/rds/client.gowalks everyDescribeReservedDBInstancesOfferingspage so it can catch a second distinct exact match. The walk is still bounded bymaxOfferingPages(5 pages ×MaxRecords=100). Before #300 a match on an early page returned right away. Now the match is held until the last page, so if a lookup hits the cap after finding a match, it fails with the same genericpagination cap reached ... (issue #688)error used when nothing matched. The error doesn't mention the match it found, and the code didn't say that this outcome was intended.Fix (decision: document as refuse-only and keep the cap)
maxOfferingPagesdoc comment now gives this reasoning.offeringPageAllowednow gets the match found so far. If the cap is reached after a match, it returns an error that names the offering, says itcannot be proven unique, and says it isrefusing to purchase (issue #303). It never returns the unverified match. When nothing matched, the old(issue #688)error is unchanged. Both errors still containpagination cap reached.paginateRDSOfferingsdoc comment, which said it returns "the first matching offering ID".No purchase path changes: before and after, this case ends in an error and no purchase. The change makes that outcome explicit and pins it with tests.
Closes #303
Verification
All evidence comes from unit tests with a mocked
MockRDSClient. No real AWS APIs were called.New tests in
providers/aws/services/rds/client_test.go:TestFindOfferingID_MatchBeforeCapRefusesWhenMorePagesRemain: 5 pages, each with a next marker, and an exact match on page 1 or on page 5. It checks for an empty ID, an error containingpagination cap reached, the matched ID,cannot be proven uniqueandrefusing to purchase, and exactlymaxOfferingPagesAPI calls (nothing fetched past the cap).TestFindOfferingID_MatchOnLastAllowedPageSucceeds: tests the boundary. A match on page 5 with no further marker completes the walk and returns the ID.Fail-before / pass-after:
The boundary test passes both before and after. It's there to guard against an off-by-one in the cap, not to show the fix.
Also run, all clean:
AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/nullwas set only because the local machine's default AWS profile is invalid. The tests don't need credentials.Not covered: a real account result set large enough to reach the cap. I haven't seen one, and this PR doesn't exercise one.
Out of scope
SQL Serverengine spelling inlookupEngineName) is in the same package and is being fixed separately. This PR leaves it alone.client.gowas already over the 500-line guideline in CLAUDE.md before this change (about 740 lines). This PR adds about 15 lines and doesn't split the file.Labels
Maintainer, please copy 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