Nobody has started this yet — be first.
Business impact
This is a revenue-accounting bug: a customer completes checkout, Commit reports success, and yet the units they just paid for silently become available for someone else to buy -- while sold (the figure that presumably drives revenue/units-sold reporting) never moves at all. Depending on which of two concurrent buyers' request wins the race for that "freed" stock, this can mean double-selling a physical unit that was already promised to someone else, and it permanently understates sales in any dashboard built on sold.
Problem
After committing a reservation, available goes back up by the committed quantity and sold never increases -- the committed stock is treated exactly like a released one.
Current behavior
applyStockEffect's case for ReasonCommit uses the same SQL as ReasonRelease/ReasonExpire (reserved -= qty, available += qty), instead of reserved -= qty, sold += qty.
Expected behavior
Committing a reservation should move its quantity from reserved into sold. available must not change as a result of a commit (it already went down when the reservation was created).
Steps to reproduce
go test ./tickets/tests/... -run TestTicket13 -vWhy this matters
applyStockEffect shares one function across commit, release, and expire because release and expire genuinely do the same thing (reserved -= qty, available += qty). Commit needs different SQL (reserved -= qty, sold += qty) -- but its case in the switch has been copy-pasted from the release/expire case instead, so it runs the exact same statement they do.
Suggested approach
Look at the two SQL strings inside applyStockEffect's switch reason in pkg/inventory/service.go, and compare them against Commit's own doc comment right above it, which already states the correct effect: "reserved -= qty, sold += qty".
Acceptance criteria
Verification
TEST_DATABASE_URL=postgresql://... go test ./tickets/tests/... -run TestTicket13 -v
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
Sign in to create it automatically, or do it yourself:
$git checkout -b fix/commit-applies-wrong-effectFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/commit-applies-wrong-effectSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign inSKIP LOCKEDhttp://localhost:8081localhost:5434flash-saleeveryday-widgetcurl localhost:8081/healthzgo run ./cmd/loadtest -url http://localhost:8081 -sku flash-sale -concurrency 10000Work the tickets in tickets/docs/ (ordered easy → hard); each names one dedicated Go test in tickets/tests/:
export TEST_DATABASE_URL=postgresql://inventory:inventory@localhost:5432/inventory_test?sslmode=disable
go test ./tickets/tests/... -run TestTicket24 -v # a single ticket
./tickets/run_tickets.sh # all 25, clean pass/fail summary
Tickets that don't touch Postgres (02, 07, 17, 19) run fine without TEST_DATABASE_URL; the rest t.Skip cleanly, not fail, if it's unset.
Level 1
Fix a bug
Read existing behaviour, correct it.