Repository navigation
fix(aws/opensearch): validate RI count before idempotency short-circuit (follow-up to #831) - #1460
Conversation
…it (follow-up to #831) PurchaseCommitment ran safeInt32Count after the idempotency guard, so a re-drive carrying an invalid instance count (negative / int32-overflow / zero) against an already-existing reservation would short-circuit to Success and never surface the bad input. Move the count validation to the boundary -- immediately after result init, before findOfferingID and the idempotency guard -- so invalid counts fail loud regardless of idempotency state (addresses the unresolved CodeRabbit Major thread on #831). Also harden the tag-failure structured-log test to assert the error= field carries the underlying cause, not just the OPENSEARCH_TAG_FAILED sentinel and commitment_id (unresolved CodeRabbit Minor thread on #831). Tests: - New TestClient_PurchaseCommitment_InvalidCount_FailsBeforeIdempotencyGuard: verified it FAILS on the pre-fix ordering (returns Success via short-circuit) and PASSES after the reorder; asserts the offering lookup and reservation describe are never reached. - TestClient_PurchaseCommitment_OfferingNotFound now sets a valid Count=1 (it previously relied on Count=0 being tolerated up to the offering lookup).
|
@coderabbitai review |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 4 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Action performedReview finished.
|
Follow-up to #831 (refs #250) — unaddressed CodeRabbit threads
Part of the adversarial-sweep over recently-merged PRs. #831 merged with two unresolved CodeRabbit threads.
F1 (Major) — invalid count bypasses validation via idempotency short-circuit
PurchaseCommitmentransafeInt32Countafter the idempotency guard, so a re-drive carrying an invalid instance count (negative / int32-overflow / zero) against an already-existing reservation would short-circuit toSuccessand never surface the bad input. Moved count validation to the boundary — immediately afterresultinit, beforefindOfferingIDand the idempotency guard.F2 (Minor) — tag-failure log test under-asserts
The
OPENSEARCH_TAG_FAILEDstructured-log test asserted only the sentinel +commitment_id; it now asserts theerror=field carries the underlying cause (a line missing the error would have passed before).Verification
TestClient_PurchaseCommitment_InvalidCount_FailsBeforeIdempotencyGuard: verified it fails on the pre-fix ordering (returns Success via short-circuit) and passes after the reorder; asserts the offering lookup + reservation describe are never reached.TestClient_PurchaseCommitment_OfferingNotFoundnow sets a validCount=1(it previously relied on Count=0 reaching the offering lookup).go build ./...,go vet, full opensearch package (55 tests) green.