Repository navigation
Conversation
…ew findings - purchase: executableByScheduler skips a direct-execute row (PlanID "") before the store instead of counting a 22P02 failure every tick, and refuses a (nil, nil) plan instead of dereferencing it (A05-013). - purchase: FinalizeInFlightRevocations waits out its retry backoff with a ctx-aware timer and stops the sweep, returning the partial counts, when ctx is done. Adds the missing table test for its accounting (A16-005). - purchase: correct the stale Azure savings-plans re-drive comments; the refusal itself is unchanged. - commitmentopts: a page-capped OpenSearch/Redshift probe records no combos for the service, so Validate stays permissive instead of rejecting combos that fell past the cap. - commitmentopts: findAWSAccount asks for enabled accounts only (A05-010). - commitmentopts: the Azure SP probe needs a Valid=true benefit to record a combo as sold (A05-012). - api: a commitment-option Validate error other than ErrNoData fails the service-config save with a 503 instead of letting it through (A02-022). Refs LeanerCloud#243 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
This branch has not been deployed
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.
Summary
Issue #243 tracks the platform half of the 2026-07-28 money-core review's medium/low findings plus five 2026-09-02 audit findings. I re-checked each one against current
main(a14dc8f2). Three were already fixed by earlier PRs. This PR fixes the remaining platform-only ones. The ladderExistingdisplay item is deferred until the go-side change lands.Refs #243
Per-finding status
d69c2024(#1042): approved rows are reaped only aftermax(reapAfter, staleApprovedThreshold + sweep interval + slack), andreaper_ordering_test.gopins the orderingf606770e(#845) +3c5a62b5(#846):PlanAndSaveLadderRunplans and inserts underpg_advisory_xact_lockper config and nets in-flight tranches inside the lock.TestLadderLock_ConcurrentRunsPlanTheGapOnce(real Postgres) shows a second concurrent run plans a zero gap. Twoladder_runsrows can still exist for one tick, but only one carries tranchesrecIsSafeToRedriveAzure SP exclusion covers 2 of 10 slugs, and its justification is stale04e65fb7, after the review) addedTestRedriveGuardReachMatchesDispatchReach. Azure only dispatchesServiceSavingsPlansAllto its SP client, and onlysavingsplans/savings-plansmap to it. A rec withsavingsplans-computegets "unsupported service" and buys nothing, so the refusal set already equals the dispatch set. This PR rewrites the stale "timestamp alias, no idempotency key" comments inmanager.go(3 places) andreaper.go. The pinned client derives the alias from the idempotency token, but nothing confirms that a repeat PUT is deduplicated, so the refusal stays as it is. Behavior is unchanged.compute) EC2 recs never getoffering_classba559138(#509):savePurchaseHistorymatchesmapServiceType(rec.Service)againstServiceEC2orServiceComputeand stamps the resolved classcommitmentopts.Validatehard-rejects legit OpenSearch/Redshift combos cut off by the page capwalkPaginatedCappedreports whethermaxPagesstopped the walk while pages remained. The two client-side-filtered probers (OpenSearch, Redshift) record no combos for a capped walk, with a warning.Validatethen takes its existing permissive "service absent" path, and the frontend keeps its hardcoded rules for that service. Probers with a server-side filter are unchangedPlanID == "") records a failure every tickautoPurchasePlanhelper returns "not eligible" forPlanID == ""before calling the store, so the row is skipped without an error. The SQS path still dead-letters it as beforeFinalizeInFlightRevocationssleeps without honoring ctxselectonctx.Done(). On cancel, the row being retried counts as Errored, the partial counts are logged, and(result, wrapped ctx.Err())is returnedExistinginstead of the netEused for the gap (cross-repo)Allocatecomputed rather than recompute it fromlayerStates. That needsNetExistingUSDPerHouronAllocate's result (LeanerCloud/cloud-commitments-go#83, not merged yet) and then a go pin bump here. A platform-only recompute ofcomputeNetExistingwould add the second copy the issue warns against, so it is left outfinalize_revocations.gohas no testfinalize_revocations_test.go: accounting table (first try / on retry / never, sharedrevokedAt), list error, cancel during backofffindAWSAccountprobes a disabled accountEnabled: true(asScheduler.enabledAccountsdoes), and the loop re-checksProviderandEnabledcheckCommitmentOptionCombolets the save through on a Validate errorErrNoDatastays permissive. Any other error is logged and returns a 503 without saving. Applies to bothPUT /api/config/service/...and account service overridesprobeComborecords a combo as sold on an emptyBenefitsslice or a nilValidflagValid=trueand none withValid=false. The two tests that pinned the old permissive behavior now assert the new rule.ProbeAzurestill has no non-test callerexecutableBySchedulerdereferences a nil plan(nil, nil)plan returns a "plan not found" error (the caller fails closed and counts it), matchingexecutePurchaseRoot cause and fix (fixed items)
executableBySchedulerpassedexec.PlanIDtoGetPurchasePlanwithout checking it and dereferenced the result without a nil check. The newautoPurchasePlanhelper (internal/purchase/manager.go) handles""→ not eligible, fetch error → wrapped error,nil→ not-found error, and!AutoPurchase→ not eligible. Splitting it out keepsexecutableBySchedulerunder the gocyclo budget.markRevokedWithRetry(internal/purchase/finalize_revocations.go), which returns(markErr, ctxErr).internal/commitmentopts/probe.go.walkPaginatedkeeps its signature as a wrapper, so the other probers and the SP prober's call site are untouched.internal/commitmentopts/service.go.internal/commitmentopts/probe_azure.go.internal/api/handler_config.go.internal/purchase/money_path_regression_test.go:TestSQSRedeliveryDoesNotDoubleExecuteran a notified, rec-bearing row with noPlanIDthrough the SQS auto-execute gate. It relied on the mock answeringGetPurchasePlan("")with an AutoPurchase plan, which real Postgres rejects with 22P02. The fixture now hasPlanID: "plan-dup". What the test checks (a redelivery doesn't double-execute) is unchanged.Verification
All evidence below is from unit tests with mocks and fakes (testify
MockConfigStore, fake AWS SDK clients, stub Azure validate client). None of these changes is DB-level (no SQL or schema change), so I added no new integration test. Finding 2's race coverage is the existing real-PostgresTestLadderLock_ConcurrentRunsPlanTheGapOnce.Fail-before: I checked out the
origin/mainversions of the changed non-test files, kept the new tests, ran them, then restored my versions:TestScheduler_DirectExecuteRowSkippedWithoutPlanLookup: FAIL.Failed=1, errorfailed to fetch plan for AutoPurchase gate: ... (SQLSTATE 22P02).TestScheduler_RefusesBeforeClaim/plan_missingandTestSQSExecutePath_RefusesBeforeClaim/plan_missing: FAIL withnil pointer dereferencepanic.TestFinalizeInFlightRevocations_CanceledDuringBackoffStopsSweep: FAIL. It took 3.00s, returned no error, and went on to the next row.TestFinalizeInFlightRevocations_Accounting/_ListErrorIsReturned: pass on both. These are the coverage tests A16-005 asked for, not regressions.TestService_FindAWSAccount_SkipsDisabled,TestAzureSPProber_EmptyBenefitsSlice,TestAzureSPProber_NilValidFlag: FAIL.TestHandler_updateServiceConfig_CommitmentOptsErrorRefusesSave: FAIL (save allowed).TestWalkPaginatedCapped_ReportsWhyTheWalkStopped,TestFilteredProbers_PageCapYieldsNoCombos/{opensearch,redshift},TestService_Validate_CappedProbeStaysPermissive: FAIL. For this run, oldprobe.gogot a compile shim,walkPaginatedCappedthat never reports a cap, which is the old behavior.Pass-after, on this branch:
Combined-tree verification. This branch was tested together with the other queued branches on a local, never-pushed tree:
queue/platform@936996ad= origin/maina14dc8f2plus these heads, merged in this order:fix/issue-72andfix/issue-312conflict on one line ininternal/api/handler_dashboard.go(both change thecalculateCommitmentMetricscall). The tree used #72's side with #312's validatedprovidervariable; whichever PR merges second takes that same resolution.Linux, Go 1.26.9,
AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true; Docker Postgres via testcontainers:936996ad:go build ./...,go vet ./...,go vet -tags integration ./...and the fullgo test -race -short -count=1 ./....936996ad: golangci-lint v2.10.1 found 0 issues on every changed package, with and without--build-tags integration.tests/e2eis a separate module, so it was vetted under its owne2etag.gocyclo -over 10is silent on the changed non-test files.-tags integration -count=1, 60-minute local timeout because the VM was shared):936996ad, these pass:internal/server,internal/credentials,internal/scheduler,internal/database/postgres/migrations,internal/purchaseandinternal/api.internal/configpasses exceptTestPostgresStoreDB_ResolveStaleRIExchange_ValidatesCloudCheck, which fails the same way on unmodified main (fixed by fix(config): compare resolve checked_at at the database's microsecond precision #1252).26795376, same branches at earlier heads):internal/analytics,internal/auth,internal/commitmentopts,internal/databaseandcmd/lambda/clear-rate-limitall pass. The later fixes don't touch those packages.httpToLambdaRequestsignature change;scripts/setup-git-secrets.shpatterns in a fresh repo with an isolated HOME, found nothing in the changed files, and a planted fake key was flagged.scripts/test-git-secrets-allowlist.sh: 137 PASS, 0 FAIL.Out of scope / notes
cloud-commitments-go/pkgpin and haveassembleLadderPlanreadNetExistingUSDPerHourfrom theAllocateresult.SavingsPlanOrderAliasPUT with the same alias name returns the existing order. Until then the refusal stays conservative.Frontend follow-up for the UI owner
No change is required. With the 503 from A02-022, the Settings save can now fail with "could not validate the commitment term and payment option; try again". The UI should already show it like any other non-2xx save error. Worth a quick look that the message reads well there.
Maintainer: please mirror the issue's triage labels onto this PR:
effort/l,type/chore,triaged,priority/p3,severity/low,urgency/eventually,impact/few.🤖 Generated with Claude Code