Skip to content

chore: Fix/strict types rooms schema#39483

Open
ggazzo wants to merge 1 commit intodevelopfrom
fix/strict-types-rooms-schema
Open

chore: Fix/strict types rooms schema#39483
ggazzo wants to merge 1 commit intodevelopfrom
fix/strict-types-rooms-schema

Conversation

@ggazzo
Copy link
Member

@ggazzo ggazzo commented Mar 9, 2026

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Task: ARCH-2048

Summary by CodeRabbit

  • Refactor
    • Refined type validation schema with more explicit object structure requirements. No changes to public APIs or end-user functionality.

…ole schema

Resolves AJV strictTypes warnings:
- missing type "object" for keyword "additionalProperties" at "#"
- missing type "object" for keyword "properties" at "#"
- missing type "object" for keyword "required" at "#/oneOf/0"
- missing type "object" for keyword "required" at "#/oneOf/1"
@ggazzo ggazzo force-pushed the fix/strict-types-rooms-schema branch from a4f2e07 to 6f05124 Compare March 9, 2026 18:36
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Mar 9, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

⚠️ No Changeset found

Latest commit: a4f2e07

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

⚠️ No Changeset found

Latest commit: 6f05124

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

Walkthrough

Refined the RoomsMembersOrderedByRoleProps JSON schema definition by adding explicit "type": "object" annotation and restructuring the oneOf validation branches to use nested-object form instead of plain required arrays.

Changes

Cohort / File(s) Summary
Schema Refinement
packages/rest-typings/src/v1/rooms.ts
Added explicit type annotation and restructured oneOf validation for RoomsMembersOrderedByRoleProps to use nested-object branches with roomId or roomName requirements.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: Fix/strict types rooms schema' directly corresponds to the changes made - adding explicit 'type': 'object' annotation and refining schema validation to address strict typing issues in the rooms schema.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.89%. Comparing base (692a891) to head (6f05124).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #39483      +/-   ##
===========================================
+ Coverage    70.87%   70.89%   +0.01%     
===========================================
  Files         3196     3196              
  Lines       113288   113299      +11     
  Branches     20531    20513      -18     
===========================================
+ Hits         80294    80321      +27     
+ Misses       30943    30930      -13     
+ Partials      2051     2048       -3     
Flag Coverage Δ
e2e 60.40% <ø> (+0.03%) ⬆️
e2e-api 47.75% <ø> (-0.02%) ⬇️
unit 71.61% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ggazzo ggazzo added this to the 8.3.0 milestone Mar 9, 2026
@ggazzo ggazzo marked this pull request as ready for review March 9, 2026 22:17
@ggazzo ggazzo requested review from a team as code owners March 9, 2026 22:17
@ggazzo
Copy link
Member Author

ggazzo commented Mar 9, 2026

/jira ARCH-1464

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/rest-typings/src/v1/rooms.ts`:
- Around line 667-670: MembersOrderedByRoleProps currently permits both roomId
and roomName as optional, but the JSON schema enforces exactly one via oneOf;
update the TypeScript type to a discriminated union so compile-time matches
runtime: replace the current MembersOrderedByRoleProps definition with a union
such as { roomId: string; roomName?: never; /* keep other props like X */ } | {
roomName: string; roomId?: never; /* keep other props like X */ }, ensuring any
other existing fields on MembersOrderedByRoleProps are preserved in both union
branches.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d5c18b12-8dfd-42bc-a123-a3ebe09cc832

📥 Commits

Reviewing files that changed from the base of the PR and between f5f2374 and 6f05124.

📒 Files selected for processing (1)
  • packages/rest-typings/src/v1/rooms.ts
📜 Review details
🧰 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:

  • packages/rest-typings/src/v1/rooms.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:18.785Z
Learning: In Rocket.Chat PR reviews, maintain strict scope boundaries—when a PR is focused on a specific endpoint (e.g., rooms.favorite), avoid reviewing or suggesting changes to other endpoints that were incidentally refactored (e.g., rooms.invite) unless explicitly requested by maintainers.
Learnt from: MartinSchoeler
Repo: RocketChat/Rocket.Chat PR: 37557
File: apps/meteor/client/views/admin/ABAC/AdminABACRooms.tsx:115-116
Timestamp: 2025-11-27T17:56:26.050Z
Learning: In Rocket.Chat, the GET /v1/abac/rooms endpoint (implemented in ee/packages/abac/src/index.ts) only returns rooms where abacAttributes exists and is not an empty array (query: { abacAttributes: { $exists: true, $ne: [] } }). Therefore, in components consuming this endpoint (like AdminABACRooms.tsx), room.abacAttributes is guaranteed to be defined for all returned rooms, and optional chaining before calling array methods like .join() is sufficient without additional null coalescing.
📚 Learning: 2025-11-27T17:56:26.050Z
Learnt from: MartinSchoeler
Repo: RocketChat/Rocket.Chat PR: 37557
File: apps/meteor/client/views/admin/ABAC/AdminABACRooms.tsx:115-116
Timestamp: 2025-11-27T17:56:26.050Z
Learning: In Rocket.Chat, the GET /v1/abac/rooms endpoint (implemented in ee/packages/abac/src/index.ts) only returns rooms where abacAttributes exists and is not an empty array (query: { abacAttributes: { $exists: true, $ne: [] } }). Therefore, in components consuming this endpoint (like AdminABACRooms.tsx), room.abacAttributes is guaranteed to be defined for all returned rooms, and optional chaining before calling array methods like .join() is sufficient without additional null coalescing.

Applied to files:

  • packages/rest-typings/src/v1/rooms.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 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:

  • packages/rest-typings/src/v1/rooms.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:

  • packages/rest-typings/src/v1/rooms.ts

Comment on lines +667 to +670
oneOf: [
{ type: 'object', required: ['roomId'] },
{ type: 'object', required: ['roomName'] },
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

helper="$(fd '^PaginatedRequest\.ts$' packages/rest-typings/src | head -n 1)"
if [ -z "$helper" ]; then
  echo "PaginatedRequest.ts not found under packages/rest-typings/src" >&2
  exit 1
fi

echo "=== PaginatedRequest definition ==="
sed -n '1,160p' "$helper"

echo
echo "=== membersOrderedByRole types + schema ==="
sed -n '630,675p' packages/rest-typings/src/v1/rooms.ts

Repository: RocketChat/Rocket.Chat

Length of output: 1241


Mirror this runtime constraint in the TypeScript type signature.

The oneOf schema now enforces exactly one of roomId or roomName, but MembersOrderedByRoleProps still declares both as optional. This allows invalid payloads like {} or { roomId, roomName } to pass type-checking while failing at runtime validation. Update the type to use a discriminated union:

Suggested type tightening
-type MembersOrderedByRoleProps = {
-	roomId?: IRoom['_id'];
-	roomName?: IRoom['name'];
-	status?: string[];
-	filter?: string;
-};
+type MembersOrderedByRoleTarget =
+	| { roomId: IRoom['_id']; roomName?: never }
+	| { roomName: IRoom['name']; roomId?: never };
+
+type MembersOrderedByRoleProps = MembersOrderedByRoleTarget & {
+	status?: string[];
+	filter?: string;
+};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rest-typings/src/v1/rooms.ts` around lines 667 - 670,
MembersOrderedByRoleProps currently permits both roomId and roomName as
optional, but the JSON schema enforces exactly one via oneOf; update the
TypeScript type to a discriminated union so compile-time matches runtime:
replace the current MembersOrderedByRoleProps definition with a union such as {
roomId: string; roomName?: never; /* keep other props like X */ } | { roomName:
string; roomId?: never; /* keep other props like X */ }, ensuring any other
existing fields on MembersOrderedByRoleProps are preserved in both union
branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant