fix(pgque.receive): reject max_return < 1 and document batch-ownership#114
fix(pgque.receive): reject max_return < 1 and document batch-ownership#114
Conversation
Add failing regression test asserting that pgque.receive(..., 0) raises an error containing 'max_return must be >= 1'. Test confirms the off-by-one bug: currently returns 1 row instead of erroring. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add input validation at the top of pgque.receive(): raise exception with message 'pgque.receive: max_return must be >= 1, got <n>' when i_max_return < 1. Fixes the off-by-one where max_return=0 returned 1 row due to exit-after-return loop ordering. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Document that max_return must be >= 1 and that ack(batch_id) always advances the consumer cursor past the full underlying batch regardless of how many rows were returned by receive(). Warns callers using partial receives to consume the full batch before acking. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
REV Review — PR #114CI: ❌ FAIL — Blocking
Non-blocking
Potential
Summary
Anti-leak: ✅ clean REV-style review (security, bugs, tests, guidelines, docs). SOC2 items skipped per project policy. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Addressing the REV blocking finding from #114 (comment): Root cause (1 sentence): Fix: Guard moved to Commit: acc362e — Diff on this branch (
CI is running — will update with |
|
CI results ( All 5 PG matrix jobs (14–18) green. |
REV Review — PR #114 (round 2)CI: PASS — BlockingNone. Non-blocking
Potential
Summary
Anti-leak: clean — diff, PR body, comments, and commit messages all scanned. REV-style review round 2 (security, bugs, tests, guidelines, docs). SOC2 items skipped per project policy. |
Summary
Closes #95.
Two related issues in
pgque.receive(queue, consumer, max_return)are fixed or documented in this PR:max_return < 1now raisespgque.receive: max_return must be >= 1, got <n>immediately, before any batch is opened. This eliminates the off-by-one wheremax_return = 0silently returned 1 row.docs/reference.mdclarifying thatack(batch_id)always advances the consumer cursor past the full underlying batch, regardless of how many rowsreceive()returned. Changing batch semantics is deferred to v0.3.Test evidence
Red commit confirmed failure before fix:
Green after fix — full suite output:
Commits
test:red regression test assertingreceive(..., 0)raises an errorfix:input guard insql/pgque.sql—raise exceptionwheni_max_return < 1docs:batch-ownership caveat added todocs/reference.mdunderpgque.receive()