test(httpapi): de-flake desc-events assertion in TestEventsAndSyncStatus#199
Conversation
The desc&limit=1 assertion in TestEventsAndSyncStatus (introduced in #196) computed `newest = ascFeed.Events[len(...)-1]` and asserted the desc call returned the same id. That races with any background event emission between the asc and desc calls — observed in CI failing with: desc&limit=1 must return newest event ("evt_3"), got "evt_4" Switch to a race-tolerant assertion: extract the numeric ordinal from the "evt_N" id and require desc_id >= asc_tail_id. The bug the assertion was designed to catch — server silently ignoring direction and returning the OLDEST event — still fails loudly (desc_id would be 1, well below the asc tail). Verified by running TestEventsAndSyncStatus 20× consecutively, all green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Relayfile Eval ReviewRun: Passed: 4 | Needs human: 0 | Reviewable: 0 | Missing output: 0 | Failed: 0 | Skipped: 0 Human Review CasesNo reviewable human-review cases captured Relayfile output. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change adds race tolerance to pagination tests by extracting numeric ordinals from event IDs. A new helper function parses event ID suffixes, and the descending pagination assertion now validates that returned events have ordinal values >= the ascending tail's ordinal, accommodating concurrent event emission between the two test requests. ChangesPagination Test Race Tolerance
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The `desc&limit=1` assertion in `TestEventsAndSyncStatus` (added in #196) races with background event emission between the asc-feed and desc-feed calls. Observed failing in CI on #198's run:
```
desc&limit=1 must return newest event ("evt_3"), got "evt_4"
```
Replace strict equality with a race-tolerant comparison: extract the numeric ordinal from `evt_N` and require `desc_id >= asc_tail_id`. The original bug-class this assertion guards against — the self-host server silently ignoring `direction=desc` and returning the OLDEST event — still fails loudly (`desc_id` would be `1`, well below the asc tail).
Test plan
🤖 Generated with Claude Code