regression: Update express OAuth route handlers on re-register - #41624
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
|
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)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (5)
|
| Layer / File(s) | Summary |
|---|---|
Shared OAuth route removal apps/meteor/server/lib/oauth/removeOAuthRoutes.ts |
Adds removeOAuthRoutes to remove matching /oauth/<service> and /_oauth/<service> route layers from the shared router. |
Provider registration cleanup apps/meteor/server/lib/oauth/configureOAuthServices.ts, apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts |
Removes existing provider routes before Passport registration and tightens the custom OAuth configuration type to include clientSecret. |
Apple OAuth reconfiguration apps/meteor/server/lib/auth-providers/apple/applePassportOAuth.ts |
Removes Apple OAuth routes after unusing the existing Apple Passport strategy during settings changes. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Possibly related PRs
- RocketChat/Rocket.Chat#40203: Modifies the custom Passport OAuth wiring used by this route cleanup.
- RocketChat/Rocket.Chat#40595: Adds a provider that calls
addPassportCustomOAuth. - RocketChat/Rocket.Chat#40679: Changes the same Passport OAuth strategy and route configuration paths.
Suggested labels: type: bug
Suggested reviewers: kevlehman, ricardogarim, tassoevan
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly matches the main fix: removing and updating OAuth handlers when services are re-registered. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| 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 💡 1
🛠️ Fix failing CI checks 💡
- Fix failing CI checks
Warning
Review ran into problems
🔥 Problems
Errors were encountered while retrieving linked issues.
Errors (1)
- CORE-2489: Request failed with status code 401
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 @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts (1)
15-15: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winMake
clientSecretrequired in the exported type.
Partial<OAuthConfiguration & { clientSecret: string }>marksclientSecretandOAuthConfigurationmembers optional. UsePartial<OAuthConfiguration> & { clientSecret: string }so the API contract reflects what the runtime guard requires.🤖 Prompt for 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. In `@apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts` at line 15, Update the exported function’s config parameter type to use Partial<OAuthConfiguration> intersected with a required clientSecret string, rather than wrapping the clientSecret field in Partial. Preserve the existing runtime guard and all other optional OAuthConfiguration properties.
🧹 Nitpick comments (2)
apps/meteor/server/lib/oauth/removeOAuthRoutes.ts (2)
13-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove implementation comments from this utility.
The repository guideline says to avoid code comments in TypeScript/JavaScript implementations; move any necessary rationale to external documentation or the PR description.
Also applies to: 27-27
🤖 Prompt for 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. In `@apps/meteor/server/lib/oauth/removeOAuthRoutes.ts` around lines 13 - 20, Remove the implementation comment block associated with the OAuth route removal utility, including the additional comment at the referenced location, while leaving the route-removal behavior and surrounding code unchanged.Source: Coding guidelines
25-28: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd regression coverage for the router-stack cleanup.
This relies on Express’s internal
router.stackandlayer.route.pathshapes. Test that both OAuth paths are removed while unrelated routes androuter.usemiddleware remain, so an Express upgrade cannot silently reintroduce stale handlers.🤖 Prompt for 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. In `@apps/meteor/server/lib/oauth/removeOAuthRoutes.ts` around lines 25 - 28, Add regression coverage for the router-stack cleanup performed by removeOAuthRoutes, verifying both OAuth paths are removed while unrelated route layers and middleware registered through router.use remain. Build the test around the router stack and layer.route.path behavior used by the implementation, preserving middleware entries during cleanup.
🤖 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.
Outside diff comments:
In `@apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts`:
- Line 15: Update the exported function’s config parameter type to use
Partial<OAuthConfiguration> intersected with a required clientSecret string,
rather than wrapping the clientSecret field in Partial. Preserve the existing
runtime guard and all other optional OAuthConfiguration properties.
---
Nitpick comments:
In `@apps/meteor/server/lib/oauth/removeOAuthRoutes.ts`:
- Around line 13-20: Remove the implementation comment block associated with the
OAuth route removal utility, including the additional comment at the referenced
location, while leaving the route-removal behavior and surrounding code
unchanged.
- Around line 25-28: Add regression coverage for the router-stack cleanup
performed by removeOAuthRoutes, verifying both OAuth paths are removed while
unrelated route layers and middleware registered through router.use remain.
Build the test around the router stack and layer.route.path behavior used by the
implementation, preserving middleware entries during cleanup.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a8f21cf7-a897-4595-b165-f2c12b5081a6
📒 Files selected for processing (4)
apps/meteor/server/lib/auth-providers/apple/applePassportOAuth.tsapps/meteor/server/lib/oauth/addPassportCustomOAuth.tsapps/meteor/server/lib/oauth/configureOAuthServices.tsapps/meteor/server/lib/oauth/removeOAuthRoutes.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: 📦 Build Packages
- GitHub Check: cubic · AI code reviewer
- GitHub Check: CodeQL-Build
- GitHub Check: Hacktron Security Check
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/server/lib/oauth/removeOAuthRoutes.tsapps/meteor/server/lib/oauth/configureOAuthServices.tsapps/meteor/server/lib/auth-providers/apple/applePassportOAuth.tsapps/meteor/server/lib/oauth/addPassportCustomOAuth.ts
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
apps/meteor/server/lib/oauth/removeOAuthRoutes.tsapps/meteor/server/lib/oauth/configureOAuthServices.tsapps/meteor/server/lib/auth-providers/apple/applePassportOAuth.tsapps/meteor/server/lib/oauth/addPassportCustomOAuth.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
apps/meteor/server/lib/oauth/removeOAuthRoutes.tsapps/meteor/server/lib/oauth/configureOAuthServices.tsapps/meteor/server/lib/auth-providers/apple/applePassportOAuth.tsapps/meteor/server/lib/oauth/addPassportCustomOAuth.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
apps/meteor/server/lib/oauth/removeOAuthRoutes.tsapps/meteor/server/lib/oauth/configureOAuthServices.tsapps/meteor/server/lib/auth-providers/apple/applePassportOAuth.tsapps/meteor/server/lib/oauth/addPassportCustomOAuth.ts
🔇 Additional comments (4)
apps/meteor/server/lib/oauth/removeOAuthRoutes.ts (1)
1-11: LGTM!Also applies to: 22-24, 29-29
apps/meteor/server/lib/oauth/configureOAuthServices.ts (1)
9-9: LGTM!Also applies to: 19-19
apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts (1)
7-7: LGTM!Also applies to: 19-19
apps/meteor/server/lib/auth-providers/apple/applePassportOAuth.ts (1)
17-17: LGTM!Also applies to: 56-56
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-8.7.0 #41624 +/- ##
=================================================
+ Coverage 68.38% 68.42% +0.04%
=================================================
Files 4139 4140 +1
Lines 158311 158318 +7
Branches 28252 28317 +65
=================================================
+ Hits 108263 108333 +70
+ Misses 44916 44854 -62
+ Partials 5132 5131 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Proposed changes (including videos or screenshots)
OAuth services are re-registered at runtime when their settings change. The passport strategy is replaced correctly, but the express routes are only appended, the old handlers are also part of execution stack.
passportOAuthCallbackisn't a request handler, but is a factory that gives out request handler function based on settings configs. Due to this the request handler always uses old handler with old settings within its closure.The fix implemented in this PR removes old request handlers from express router stack before pushing new handlers. In future we can come up with a better fix to not sure factory and closures, where express route handlers can use new settings directly.
Issue(s)
Steps to test or reproduce
Further comments
CORE-2489
Summary by CodeRabbit