chore: audit polish — migration test scoping, dead fallback, OAuth guard test, failure counters#3960
Conversation
…ard test, failure counters Batches 4 small audit findings: scope the signup-grant backfill migration integration test to its own seeded fixture ids (was crediting any leftover grant-plan org in the shared collection), drop the unreachable `result.plan || 'free'` fallback plus the unit test that forced it via an impossible repository return shape, add a regression test that registers a REAL passport strategy so a passport upgrade renaming the private `_strategy` API fails CI instead of silently 404-ing OAuth logins, and differentiate the migration's `failed` counter into planNotFound/guardStripped/error buckets. Closes #3954 Claude-Session: https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds real-passport OAuth regression coverage, classifies signup-grant migration failures, scopes migration integration tests to fixtures, and makes organization creation events emit a constant ChangesOAuth passport guard
Signup grant backfill diagnostics
Organization creation event
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3960 +/- ##
=======================================
Coverage 92.71% 92.71%
=======================================
Files 169 169
Lines 5573 5573
Branches 1792 1791 -1
=======================================
Hits 5167 5167
Misses 326 326
Partials 80 80
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@modules/billing/tests/billing.migration.backfill-signup-grant.integration.tests.js`:
- Around line 47-69: Update runScopedMigration’s mocked organizations collection
to return a Proxy around the real collection instead of a duck-typed object.
Intercept find to merge the fixture _id restriction with the migration filter,
while delegating all other property accesses and method calls to the real
collection with the correct collection receiver.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: baf80db2-1104-4038-b34a-e0cdda3296d3
📒 Files selected for processing (6)
modules/auth/tests/auth.oauthCall.realPassportGuard.unit.tests.jsmodules/auth/tests/fixtures/auth-controller.mock-setup.jsmodules/billing/migrations/20260707100000-backfill-missing-signup-grant-credits.jsmodules/billing/tests/billing.migration.backfill-signup-grant.integration.tests.jsmodules/organizations/services/organizations.crud.service.jsmodules/organizations/tests/organizations.crud.grant.unit.tests.js
💤 Files with no reviewable changes (1)
- modules/organizations/tests/organizations.crud.grant.unit.tests.js
Summary
find()-filter intersection spy — the real migration logic (plan filter,grantOnSignupdelegation, idempotency) is untouched, only the test's blast radius on the sharedorganizationscollection is.result.plan || 'free'fallback inorganizations.crud.service.js::create(plan: 'free'is set unconditionally above) and aligned theorganization.createdemit to the literal'free'used at the sibling call site (organizations.service.js::createOrganizationForUser).isEnabledOAuthProvider— registers a trivial strategy viapassport.use()so a future passport upgrade renaming/removing the private_strategyAPI fails loudly in CI instead of silently 404-ing OAuth logins (kept in its own file:unstable_mockModule('passport', ...)factories are sticky per test file).failedcounter intoplanNotFound/guardStripped/errorbuckets by pre-classifying with the same read-only, config-static plan lookupgrantOnSignupuses internally, before calling it — never short-circuits the real call, only sharpens the log.Scope
nonelowValidation
npm run lintnpm testGuardrails check
.env*,secrets/**, keys, tokens)Notes for reviewers
https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
Summary by CodeRabbit
Bug Fixes
Reliability