Skip to content

test(oauth): await secret index before stored-row races - #2635

Merged
lilyshen0722 merged 1 commit into
mainfrom
flint/stored-row-ordering
Oct 24, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
flint/stored-row-ordering

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

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

Deterministic stored-row race setup

Tier: 0 (test-only). Requested after merge-group run 40098650298 bounced #2403.

The callback and refresh race tests depend on ConnectorSecret's unique (integrationId, kind) index. Loading the model starts index creation asynchronously. If a stale upsert runs before that build completes, Mongo can create another row; the requests then fail at the later callback/refresh fence with state_consumed / HostedMcpCredentialError, rather than the asserted secret-store refusal.

The suite now awaits ConnectorSecret.init() before any test runs. Secret upsert ordering and every assertion remain unchanged. No production changes or clock sleeps.

Proof

  • Deliberately dropping only that index reproduces both exact CI mismatches: 2 failed, 10 passed.
  • With setup awaiting initialization: 20 independent full-file Jest invocations, 12/12 each (240 passing assertions/cases), zero failures.
  • Command: npm --prefix backend test -- --runInBand __tests__/unit/routes/hostedMcpConnect.storedRow.test.js with Node 22.
  • git diff --check passes.

CI failure evidence: merge-group run 40098650298. Fresh CI and CodeRabbit must finish before press.

Co-authored-by: flint <WyJmbGludCIsImRlZmF1bHQiXQ@agents.commonly.invalid>
Agent-Model: codex/gpt-6.1-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 3021cf9 and 7d3d0c2.

Files selected for processing: 1
  • backend/__tests__/unit/routes/hostedMcpConnect.storedRow.test.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Walkthrough

The hosted MCP connect test setup now awaits ConnectorSecret.init() after connecting to MongoDB. This ensures index initialization completes before the tests run.

Changes: Connector secret test setup

Layer / File(s) Summary
Await index initialization
backend/__tests__/unit/routes/hostedMcpConnect.storedRow.test.js
The beforeAll setup awaits ConnectorSecret.init() after connecting to MongoDB.

Priority: Low

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

Change: Other

Possibly related PRs

Merge Risk: Minimal · up to 7d3d0

No actionable merge-blocking risk remains; the test setup now establishes the required unique index before exercising the races.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly describes the test-only change: awaiting the secret index before stored-row OAuth race tests.
Description check Passed The description directly explains the race condition, the ConnectorSecret.init() setup change, validation results, and test scope.
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.
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

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.

TIER 0 PRESS CHECK at 7d3d0c2.

This PR changes one test file, backend/tests/unit/routes/hostedMcpConnect.storedRow.test.js, with no production code. Every CodeRabbit thread is answered (cr-unanswered: 0), and CI at this head is green.

GATE: PASS

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit 451b4eb Oct 24, 2026
22 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