Repository navigation
fix(purchase): map session approve and direct execute failures by cause - #644
Merged
Merged
Conversation
Session approve and direct execute answered 409 for every error, including failures after the claim where money may have moved, and direct execute stamped executed_at before the claim, so a refused run kept it. ApproveAndExecute now returns the row, and a new DirectExecute stamps the executed_* audit fields only after the claim is won. Both handlers map errors through executeFailureError (renamed from runNowError): 403 for a four-eyes denial, 409 for a lost claim, 500 before the claim, 502 with the row's status after it. Refs #532
Contributor
|
Warning Review limit reached
This review includes 15 billable files and costs up to $3.75.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 6 minutes for your next included review. View limit detailsLimit details: You’ve used the included review currently available. Your 69 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (15)
Comment |
This was referenced Oct 9, 2026
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.
Refs #532. Slice 1 of 4 (plan: #532 (comment)).
What changed
ApproveAndExecutereturns the row (likeRunPlannedPurchaseNow), so handlers can tell a lost claim from a failure after the claim.Manager.DirectExecute: same funnel, stampsexecuted_at/executed_by_user_id/pre_approval_skip_reasononly once the CAS is won. The handler no longer saves them before the claim.runNowErroris nowexecuteFailureError(executionID, action, final, err), shared by run-now, session approve and direct execute.openapi.yaml: 502 added to approve (session mode) and execute (direct mode); approve 409 text no longer lists execution failure.Mapping (same as run-now)
Decisions for the owner
Proof
Before: handler_purchases.go:851 and :3179 returned 409 for every error, and :3158 stamped ExecutedAt before the claim. The new tests fail when
executeFailureErroris mutated to answer 409 for the post-claim case (verified), and the DirectExecute stamp test fails when the skip reason is removed (verified). The existing 4-eyes direct-execute tests (real manager) were asserting the old 409 and now assert 403 and that no save carries ExecutedAt.go test -race -short ./...,go vet ./...,go vet -tags integration ./internal/...: pass. OpenAPI tests pass. errcheck -blank, shadow, unparam, gocritic, misspell: nothing new in changed lines.