-
Notifications
You must be signed in to change notification settings - Fork 12.8k
chore: Throw error if deprecation endpoint deprecated should be removed #36647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: eb67ea9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 40 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-8.0.0 #36647 +/- ##
=================================================
+ Coverage 66.43% 68.42% +1.98%
=================================================
Files 3276 2877 -399
Lines 109596 101934 -7662
Branches 20860 17729 -3131
=================================================
- Hits 72814 69747 -3067
+ Misses 34116 30538 -3578
+ Partials 2666 1649 -1017
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
33ea06e to
9505de9
Compare
9588c6c to
c9f8809
Compare
9e4dba8 to
9aacd32
Compare
e19fae0 to
0d1c2a5
Compare
78a372d to
5a6c610
Compare
WalkthroughAdds an early deprecation guard in ApiClass.addRoute that throws when a route's deprecation version should break, bumps planned deprecation version to Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller as addRoute caller
participant Api as ApiClass.addRoute
participant Dep as shouldBreakInVersion
participant Router as Route registry
Caller->>Api: addRoute(route, options, action)
Api->>Api: inspect options.deprecation
alt deprecation present
Api->>Dep: shouldBreakInVersion(options.deprecation.version)
Dep-->>Api: true
Api-->>Caller: throw Meteor.Error('error-deprecated', "The endpoint {route} should be removed")
Note over Api,Caller: Registration aborted before wrapping/registration
else not breaking
Api->>Router: register wrapped action (auth, rate-limit, perms, error handling)
Router-->>Caller: route registered
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (5)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (1)📚 Learning: 2025-09-19T15:15:04.642ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (4)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/meteor/app/api/server/ApiClass.ts (1)
808-810: Fail-fast removal guard: enrich error and confirm startup-crash intentThrowing during route registration will fail server startup once the planned version is reached. If that’s the goal, keep it—otherwise gate behind an env flag or only enforce in CI/TEST.
Minimal improvement: include method and planned version to aid triage.
- if (options.deprecation && shouldBreakInVersion(options.deprecation.version)) { - throw new Meteor.Error('error-deprecated', `The endpoint ${route} should be removed`); - } + if (options.deprecation && shouldBreakInVersion(options.deprecation.version)) { + const planned = options.deprecation.version; + throw new Meteor.Error( + 'error-deprecated', + `The endpoint ${this.getFullRouteName(route, method)} is scheduled for removal in ${planned} and must be removed`, + { endpoint: route, method, planned }, + ); + }If you prefer a softer rollout aligned with the logger’s env knob, consider:
// near other consts const hardFailDeprecatedRoutes = process.env.ROCKET_CHAT_DEPRECATION_HARD_FAIL !== 'false';- if (options.deprecation && shouldBreakInVersion(options.deprecation.version)) { + if (options.deprecation && shouldBreakInVersion(options.deprecation.version) && hardFailDeprecatedRoutes) { // throw... }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/meteor/app/api/server/ApiClass.ts(1 hunks)apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/meteor/app/api/server/ApiClass.ts (1)
apps/meteor/server/lib/shouldBreakInVersion.ts (1)
shouldBreakInVersion(5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: 📦 Build Packages
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
🔇 Additional comments (1)
apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts (1)
27-27: Type narrowed to '9.0.0' — repo still contains '7.0.0' callers; update callers or centralizeScan found these literal occurrences — update them to match the new planned version or centralize the version constant:
- apps/meteor/client/views/admin/workspace/VersionCard/getVersionStatus.spec.ts:175,183
- apps/meteor/ee/server/api/engagementDashboard/channels.ts:63
- apps/meteor/app/authorization/server/methods/removeUserFromRole.ts:44
- apps/meteor/app/authorization/server/methods/addUserToRole.ts:44
- apps/meteor/app/api/server/v1/oauthapps.ts:296 (apiDeprecationLogger.parameter(..., '7.0.0', ...))
Optional refactor (centralize the version):
-export type DeprecationLoggerNextPlannedVersion = '9.0.0'; +export const NEXT_BREAKING_VERSION = '9.0.0' as const; +export type DeprecationLoggerNextPlannedVersion = typeof NEXT_BREAKING_VERSION;
f6eaabb to
70fdc50
Compare
97cd0ad to
7188097
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/meteor/app/api/server/ApiClass.ts (1)
810-812: LGTM! Consider enhancing the error message with version info.The pre-registration deprecation guard correctly prevents deprecated endpoints from being registered when they should break in the current version. This fail-fast approach ensures deprecated endpoints are removed before release.
Consider including the deprecation version in the error message for better developer experience:
- if (options.deprecation && shouldBreakInVersion(options.deprecation.version)) { - throw new Meteor.Error('error-deprecated', `The endpoint ${route} should be removed`); - } + if (options.deprecation && shouldBreakInVersion(options.deprecation.version)) { + throw new Meteor.Error('error-deprecated', `The endpoint ${route} should be removed (deprecated since ${options.deprecation.version})`); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
apps/meteor/app/api/server/ApiClass.ts(1 hunks)apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/meteor/app/api/server/ApiClass.ts (1)
apps/meteor/app/livechat/server/methods/getAnalyticsChartData.ts (1)
options(18-38)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: 📦 Build Packages
- GitHub Check: Builds matrix rust bindings against alpine
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
🔇 Additional comments (1)
apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts (1)
27-27: Type alias matches the new removal target.Locking
DeprecationLoggerNextPlannedVersionto'9.0.0'enforces the cleanup of anything slated for ≤8.x before this release, which is exactly what we want here. 👍
7188097 to
ddb885e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/meteor/app/api/server/ApiClass.ts (1)
810-812: Good enforcement strategy; consider enriching the error message.Throwing at registration time (during startup) is the right approach to prevent deprecated endpoints from being used past their removal deadline. This ensures teams can't accidentally deploy code with expired deprecations.
Consider including the deprecation version in the error message for better debugging:
-if (options.deprecation && shouldBreakInVersion(options.deprecation.version)) { - throw new Meteor.Error('error-deprecated', `The endpoint ${route} should be removed`); -} +if (options.deprecation && shouldBreakInVersion(options.deprecation.version)) { + throw new Meteor.Error('error-deprecated', `The endpoint ${route} is deprecated for version ${options.deprecation.version} and should be removed`); +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
apps/meteor/app/api/server/ApiClass.ts(1 hunks)apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/meteor/app/api/server/ApiClass.ts (1)
apps/meteor/app/livechat/server/methods/getAnalyticsChartData.ts (1)
options(18-38)
d14079a to
381143c
Compare
f335608 to
0027044
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/meteor/app/api/server/ApiClass.ts (1)
817-819: Enhance error message to include deprecation version for better developer experience.The deprecation guard correctly prevents registration of endpoints marked for removal in the current version. However, the error message could be more informative by including the deprecation version, helping developers understand why removal is required.
🔎 Suggested enhancement
if (options.deprecation && shouldBreakInVersion(options.deprecation.version)) { - throw new Meteor.Error('error-deprecated', `The endpoint ${route} should be removed`); + throw new Meteor.Error('error-deprecated', `The endpoint ${route} was marked for removal in version ${options.deprecation.version} and must be removed`); }Optional efficiency improvement: The rate limiter rules are added (lines 789-795) before this deprecation check. Consider moving this check earlier in the method to avoid unnecessary setup for endpoints that will be rejected. However, this is a minor optimization since the endpoint won't register anyway.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
apps/meteor/app/api/server/ApiClass.ts(1 hunks)apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts
🧰 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/app/api/server/ApiClass.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/meteor/app/api/server/helpers/parseJsonQuery.ts(2 hunks)apps/meteor/app/e2e/server/methods/updateGroupKey.ts(0 hunks)apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts(6 hunks)
💤 Files with no reviewable changes (1)
- apps/meteor/app/e2e/server/methods/updateGroupKey.ts
🧰 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/app/api/server/helpers/parseJsonQuery.tsapps/meteor/app/lib/server/lib/deprecationWarningLogger.ts
🧠 Learnings (1)
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts
Applied to files:
apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts
🧬 Code graph analysis (1)
apps/meteor/app/api/server/helpers/parseJsonQuery.ts (1)
apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts (1)
apiDeprecationLogger(29-101)
🔇 Additional comments (3)
apps/meteor/app/api/server/helpers/parseJsonQuery.ts (1)
60-60: Version bump correctly addresses previous review feedback.The deprecation version has been updated from '8.0.0' to '9.0.0' for both
fieldsandqueryparameters, aligning with the type narrowing indeprecationWarningLogger.tsand addressing the past review comment about updating all call sites.Also applies to: 109-109
apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts (2)
27-27: Type narrowing to '9.0.0' is correct.The type has been appropriately narrowed to enforce the new planned deprecation version across all deprecation logger call sites.
34-36: TEST_MODE guards correctly enforce deprecations in test mode.The TEST_MODE guards are properly placed before
compareVersionsand other deprecation processing, ensuring that tests fail immediately when deprecated APIs are invoked. This aligns with the PR objective to add error throwing for deprecation warnings in test mode.Also applies to: 88-90, 112-114, 121-123, 145-147, 157-159
7254b63 to
f9e1ff2
Compare
35b6d32 to
aee918d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts (1)
59-63: Fix TEST_MODE guard ordering in parameter method.The TEST_MODE guard is placed after
compareVersions(line 59), creating inconsistent behavior with all other deprecation logger methods where the guard precedes version comparison. IfcompareVersionsthrows whenROCKET_CHAT_DEPRECATION_THROW_ERRORS_FOR_VERSIONS_UNDERis set, the TEST_MODE guard never executes, defeating its purpose.🔎 Proposed fix to move TEST_MODE guard before compareVersions
}) ?? `The parameter "${parameter}" in the endpoint "${endpoint}" is deprecated and will be removed on version ${version}`; - compareVersions(version, message); - if (process.env.TEST_MODE === 'true') { throw new Error(message); } + compareVersions(version, message); + metrics.deprecations.inc({ type: 'parameter-deprecation', kind: 'endpoint', name: endpoint, params: parameter });
🧹 Nitpick comments (1)
apps/meteor/app/api/server/ApiClass.ts (1)
817-819: Consider enhancing the error message with the deprecation version.The error message could be more helpful by including the deprecation version, making it clearer why the endpoint must be removed.
🔎 Suggested enhancement
if (options.deprecation && shouldBreakInVersion(options.deprecation.version)) { - throw new Meteor.Error('error-deprecated', `The endpoint ${route} should be removed`); + throw new Meteor.Error('error-deprecated', `The endpoint ${route} was marked for removal in version ${options.deprecation.version} and must be removed`); }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
apps/meteor/app/api/server/ApiClass.ts(1 hunks)apps/meteor/app/api/server/helpers/parseJsonQuery.ts(2 hunks)apps/meteor/app/e2e/server/methods/updateGroupKey.ts(0 hunks)apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts(6 hunks)
💤 Files with no reviewable changes (1)
- apps/meteor/app/e2e/server/methods/updateGroupKey.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/meteor/app/api/server/helpers/parseJsonQuery.ts
🧰 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/app/api/server/ApiClass.tsapps/meteor/app/lib/server/lib/deprecationWarningLogger.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
f9e1ff2 to
092f90d
Compare
dc95dea to
e805619
Compare
092f90d to
7596652
Compare
e805619 to
3f76e7a
Compare
e06b0cd to
ee2a34f
Compare
3f76e7a to
b5daa07
Compare
…PlannedVersion type
… parameters in parseJsonQuery helper
b5daa07 to
eb67ea9
Compare
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.