Nobody has started this yet — be first.
Business impact
ingest_batch's own docstring (still accurate!) explains the intended contract: partial success returns 200 with a per-event accepted/rejected breakdown, and only a complete failure returns 503. The actual condition governing that decision now fires the 503 branch whenever any event in the batch was rejected — even if 999 out of 1000 were accepted. A client watching for 503 as its signal to back off will back off far more aggressively than the real queue state warrants, and a monitoring dashboard counting 503s as "total outage" moments will register one for every batch that merely brushed up against a momentarily-full queue.
Problem
ingest_batch's own docstring describes the intended contract: partial success returns 200 with an accepted/rejected breakdown, and only a complete failure returns 503. The actual guard governing that decision fires the 503 branch whenever any event in the batch was rejected, even if nearly all of them succeeded.
Current behavior
ingest_batch guards with if accepted == 0 or rejected > 0: raise HTTPException(503, ...) — the or means a single rejected event anywhere in a large, mostly-successful batch discards the whole successful response.
Expected behavior
Only raise 503 when nothing in the batch was accepted; any batch with at least one accepted event should return 200 with the real {submitted, accepted, rejected} breakdown.
Steps to reproduce
pytest practice_tickets/tests/test_ticket_08_batch_partial_success.py -v — uses a stalled fake DB backend and a queue sized to accept some but not all of a batch, then checks the response status.Why this matters
and vs or in a two-term boolean guard is one of the easiest things to get backwards, especially when the intended English ("fail only if nothing got through") has to be translated into "accepted is zero AND rejected is nonzero" — it's tempting to instead write "if there's any sign of trouble at all," which is a different, broader condition that silently swallows every partially-successful response.
Suggested approach
Read ingest_batch's own docstring in app/routers/events.py — it already states the intended contract precisely. Compare that stated contract against the actual if condition a few lines below it.
Acceptance criteria
Verification
pytest practice_tickets/tests/test_ticket_08_batch_partial_success.py -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/batch-503-on-partial-successFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/batch-503-on-partial-successSubmit 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 inhttp://localhost:8000localhost:5432curl localhost:8000/healthzcurl localhost:8000/readyzWork the tickets in practice_tickets/tickets/ (ordered easy → hard); each names one dedicated test in practice_tickets/tests/:
pytest practice_tickets/tests/test_ticket_01_persisted_count.py -v # a single ticket
./practice_tickets/run_tickets.sh # all 20, clean pass/fail summary
TICKET-17 needs a real Postgres to run at all (it checks which column a value lands in, which no fake/in-memory DB backend can meaningfully verify) — set TEST_DATABASE_URL=postgresql://<you>@localhost/ingest_test before running it or the full suite; without it, that one test is skipped, not failed.
Level 1
Fix a bug
Read existing behaviour, correct it.