fix: narrow IModerationReport ts type from Date | string to Date#39641
fix: narrow IModerationReport ts type from Date | string to Date#39641Avanish-Gupta-CSE wants to merge 1 commit into
Conversation
Resolves RocketChat#39551. The Date | string union generated a oneOf in JSON Schema where an ISO date string matched both branches, causing AJV validation to fail with passingSchemas: 0,1. Since MongoDB stores ts as Date and JSON serialization produces ISO strings matching date-time format, narrowing to Date eliminates the oneOf and fixes validation. Made-with: Cursor
|
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: 4162b0d The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
📜 Recent review details⏰ 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). (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (12)📓 Common learnings📚 Learning: 2026-01-17T01:51:47.764ZApplied to files:
📚 Learning: 2026-03-12T10:26:26.697ZApplied to files:
📚 Learning: 2026-03-10T08:13:52.153ZApplied to files:
📚 Learning: 2026-03-06T18:09:17.867ZApplied to files:
📚 Learning: 2026-03-03T11:11:48.541ZApplied to files:
📚 Learning: 2025-09-25T09:59:26.461ZApplied to files:
📚 Learning: 2025-09-25T09:59:26.461ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-25T20:10:16.987ZApplied to files:
📚 Learning: 2025-12-10T21:00:54.909ZApplied to files:
🔇 Additional comments (4)
WalkthroughThe changes narrow the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
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 Tip CodeRabbit can use oxc to improve the quality of JavaScript and TypeScript code reviews.Add a configuration file to your project to customize how CodeRabbit runs oxc. |
Proposed changes (including videos or screenshots)
Narrows the
tstype onIModerationReportfromDate | stringtoDate, fixing the AJVoneOfvalidation failure described in #39551.Changes:
packages/core-typings/src/IModerationReport.ts- Changedts: Date | stringtots: Dateapps/meteor/app/api/server/v1/moderation.ts- Removed 5 TODO workaround comment blocks (30 lines) that documented theoneOfissuedocs/api-endpoint-migration.md- Updated "Known Pitfall" section to document the fix.changeset/fix-moderation-audit-ts-type.md- Added changeset for@rocket.chat/core-typingsand@rocket.chat/meteorRoot cause
IModerationReport.tsdefinedts: Date | string. When typia generates JSON Schema from this union, it creates aoneOfwith:{ type: "string", format: "date-time" }(forDate){ type: "string" }(forstring)An ISO date string like
"2026-03-11T16:07:21.755Z"matches both branches, causing AJVoneOfto fail withpassingSchemas: 0,1.Why
Dateis correctts: new Date()(bothcreateWithMessageDescriptionAndUserIdandcreateWithDescriptionAndUserinModerationReports.ts)tsas a nativeDateobjectdate-timeformat validationResolves #39551
Issue(s)
Closes #39551
Steps to test or reproduce
moderation.reportsByUsers,moderation.userReports, etc.) no longer fail AJV validation when returning reports with ISO date stringtsfieldsFurther comments
The inline AJV schemas in
moderation.ts(which manually definets: { type: 'string' }) remain functionally correct and are kept as-is. The TODO workaround comments are removed since the root cause is now fixed at the type level.Made with Cursor
Summary by CodeRabbit
Bug Fixes
Documentation