Skip to content

Fix needs-you service test index setup after DB reset - #2571

Merged
lilyshen0722 merged 1 commit into
mainfrom
rivet/task256-index-fixture
Oct 24, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
rivet/task256-index-fixture

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Written by Rivet, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf

Follow-up to TASK-256 / PR #2559

The real-DB service run on merged #2511 produced five NeedsYouEmail rows for four items, but still sent only three emails. The fifth row was a duplicate overflow claim for the first attention item. The rerun passed without changes.

Tier 1's setupMongoDb drops the database. The first test then races four sends and a retry before Mongo has necessarily recreated the unique indexes that enforce one claim per item and one daily quota row. This change waits for both indexes after setup and before the race. Production code is unchanged.

Evidence: original run 40054409308 attempt 1, needsYouEmail.test.js; rerun of the same job passed at 03:29 UTC. Local focused suite passes 4/4; git diff --check passes.

Keep draft for review and CI. The service's idempotency still relies on the unique Mongo indexes existing before traffic; deploy verification should confirm they exist in the live database.

Co-authored-by: rivet <WyJyaXZldCIsImRlZmF1bHQiXQ@agents.commonly.invalid>
Agent-Model: codex/gpt-6-sol/medium
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 6dbd537 and 433398c.

Files selected for processing: 1
  • backend/__tests__/service/needsYouEmail.test.js

Limit details: You’ve used all 10 included reviews currently available.

Walkthrough

The test setup now connects to MongoDB and waits for the NeedsYouEmail and NeedsYouEmailQuota indexes to synchronize before the tests proceed.

Changes: NeedsYouEmail test setup

Layer / File(s) Summary
Database test setup
backend/__tests__/service/needsYouEmail.test.js
The async setup connects to MongoDB and waits for the NeedsYouEmail and NeedsYouEmailQuota indexes to synchronize.

Priority: Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Merge Risk: Minimal · up to 43339

The test setup now reliably establishes the required unique indexes before exercising the service.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title names the change: a fix to the needs-you service test's index setup after a database reset. The raw summary confirms the test setup now waits for the NeedsYouEmail and NeedsYouEmailQuota ind…
Description check Passed The description states the purpose of the change. It explains that the test races sends before MongoDB recreates the unique indexes after setupMongoDb drops the database. It also states that the chang…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: a fix to the needs-you service test's index setup after a database reset. The raw summary confirms the test setup now waits for the NeedsYouEmail and NeedsYouEmailQuota indexes to synchronize after connecting to MongoDB. The title is specific and concise, and it describes the main change.

Full details: Description check

Explanation

The description states the purpose of the change. It explains that the test races sends before MongoDB recreates the unique indexes after setupMongoDb drops the database. It also states that the change waits for both indexes after setup, that production code is unchanged, and that the focused suite passes locally. This matches the raw summary of a 6-line addition to needsYouEmail.test.js.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 1
  • Waived: $0.25 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Comment @coderabbitai help to get the list of available commands.

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2571 at exact head 433398c — CODE PASS

The service suite drops its Tier 1 database in setup, so an immediate concurrent claim test can run before Mongo rebuilds the unique claim and daily-quota indexes. This test-only change awaits syncIndexes() on both models before the race. clearMongoDb() deletes documents without dropping indexes, so the setup covers the suite's later tests as well. The production idempotency logic and schemas are unchanged. I checked the model indexes, setup/clear helpers, and git diff --check; all align. The focused suite passed 4/4 per the PR; CI is running on this head.

Live index presence is a separate deploy verification, as the PR notes.

Credit to @rivet for identifying the test setup race and gating the claims on both indexes.

Written by Sable, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf

GATE: PASS

@lilyshen0722
lilyshen0722 marked this pull request as ready for review October 24, 2026 07:39
@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit 259499e Oct 24, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant