Skip to content

chore: Add OpenAPI Support to custom-user-status.list API#36916

Merged
ggazzo merged 2 commits intoRocketChat:developfrom
ahmed-n-abdeltwab:feat/openapi-custom-user-status-list
Feb 23, 2026
Merged

chore: Add OpenAPI Support to custom-user-status.list API#36916
ggazzo merged 2 commits intoRocketChat:developfrom
ahmed-n-abdeltwab:feat/openapi-custom-user-status-list

Conversation

@ahmed-n-abdeltwab
Copy link
Copy Markdown
Contributor

@ahmed-n-abdeltwab ahmed-n-abdeltwab commented Sep 11, 2025

Description:
This PR integrates OpenAPI support into the Rocket.Chat API, migrate of Rocket.Chat API endpoints to the new OpenAPI pattern. The update includes improved API documentation, enhanced type safety, and response validation using AJV.

Key Changes:

  • Implemented the new pattern and added AJV-based JSON schema validation for API.
  • Uses the ExtractRoutesFromAPI utility from the TypeScript definitions to dynamically derive the routes from the endpoint specifications.
  • Enabled Swagger UI integration for this API.
  • Route Methods Chaining for the endpoints.
  • This does not introduce any breaking changes to the endpoint logic.

Issue Reference:
Relates to #34983, part of the ongoing OpenAPI integration effort.

Testing:

  • Verified that the API response schemas are correctly documented in Swagger UI.

  • All tests passed without any breaking changes

    $ yarn testapi -f '[CustomUserStatus]'                       
    
      [CustomUserStatus]
      [/custom-user-status.list]
        ✔ should return custom user status (40ms)
        ✔ should return custom user status even requested with count and offset params
        ✔ should return one custom user status when requested with id param
        ✔ should return empty array when requested with an existing name param
        ✔ should return empty array when requested with unknown name param
    
    
    5 passing (904ms)

Endpoints:

Looking forward to your feedback! 🚀

Summary by CodeRabbit

  • New Features
    • OpenAPI-backed, schema-validated custom-user-status list with pagination and structured responses.
  • Documentation
    • Improved API documentation and discoverability for custom user status operations.
  • Refactor
    • List endpoint migrated to a modern, schema-driven routing approach with formal request/response contracts and error handling.
  • Chores
    • Patched related typing/dependency packages and updated public REST typings for custom-user-status endpoints.

COMM-144
Task: ARCH-1986

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Sep 11, 2025

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

  • This PR is missing the 'stat: QA assured' label
  • This PR is targeting the wrong base branch. It should target 8.3.0, but it targets 8.2.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Sep 11, 2025

🦋 Changeset detected

Latest commit: ed41fa2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Minor
@rocket.chat/core-typings Minor
@rocket.chat/rest-typings Minor
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Major
@rocket.chat/ui-client Major
@rocket.chat/ui-contexts Major
@rocket.chat/ui-voip Major
@rocket.chat/web-ui-registration Major
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Major
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 11, 2025

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Converts the custom-user-status.list route to a typed, AJV-validated chained endpoint and exports its endpoint types which augment @rocket.chat/rest-typings; adds ICustomUserStatus to shared AJV schemas; removes the list endpoint types and related AJV/pagination declarations from consolidated rest-typings; adds a changeset patching three packages.

Changes

Cohort / File(s) Summary
Changeset
​.changeset/sweet-terms-relax.md
Adds a changeset recording patch releases for @rocket.chat/meteor, @rocket.chat/core-typings, and @rocket.chat/rest-typings.
Server API refactor
apps/meteor/app/api/server/v1/custom-user-status.ts
Replaces inline API.v1.addRoute with a typed chained endpoint (customUserStatusEndpoints); introduces AJV request validation and typed 200/400/401 responses; moves handler into action() with pagination, filter parsing, and returns ICustomUserStatus items; exports CustomUserStatusEndpoints and augments rest typings.
Shared AJV schemas
packages/core-typings/src/Ajv.ts
Adds ICustomUserStatus to the typia-generated JSON schema union used by shared AJV schemas.
REST typings update
packages/rest-typings/src/v1/customUserStatus.ts
Removes the list endpoint types, AJV list schema/validator, and PaginatedRequest/PaginatedResult references; defines CustomUserStatusEndpoints for create/update/delete and updates imports to only include ICustomUserStatus.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant API as API.v1 (custom-user-status.list)
  participant V as AJV Validator
  participant S as action()
  participant DB as CustomUserStatus Model

  rect rgba(236,246,255,0.5)
  note over API,V: Request validation (CustomUserStatusListSchema)
  C->>API: GET /v1/custom-user-status.list?name&_id&offset&count
  API->>V: validate(params)
  V-->>API: valid / invalid
  alt invalid
    API-->>C: 400 Bad Request
  else valid
    API->>S: action(params)
    S->>S: compute pagination (getPaginationItems)
    S->>DB: findPaginated(filter, sort, skip, limit)
    DB-->>S: { statuses, total }
    S-->>API: { statuses, count, offset, total, success }
    API-->>C: 200 OK
  end
  end

  rect rgba(255,244,244,0.5)
  note over API: Auth failure
  API-->>C: 401 Unauthorized
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I nibble at schemas, neat and bright,
Routes hop forward in morning light;
AJV hums, checks every line,
Types align, responses shine.
A carrot patch of endpoints—cheers! 🥕🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately describes the main change: adding OpenAPI support to the custom-user-status.list API endpoint, which is the primary focus across all modified files.

✏️ 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
Copy Markdown

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.61%. Comparing base (c117492) to head (ed41fa2).
⚠️ Report is 115 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #36916      +/-   ##
===========================================
- Coverage    70.63%   70.61%   -0.02%     
===========================================
  Files         3189     3189              
  Lines       112717   112717              
  Branches     20390    20457      +67     
===========================================
- Hits         79621    79600      -21     
- Misses       31048    31066      +18     
- Partials      2048     2051       +3     
Flag Coverage Δ
e2e 60.35% <ø> (-0.04%) ⬇️
e2e-api 47.87% <ø> (+0.07%) ⬆️
unit 71.17% <ø> (-0.02%) ⬇️

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.

@cardoso cardoso marked this pull request as ready for review September 11, 2025 11:38
@cardoso cardoso requested review from a team as code owners September 11, 2025 11:38
@cardoso cardoso requested a review from Copilot September 11, 2025 11:38
Copy link
Copy Markdown
Member

@cardoso cardoso left a comment

Choose a reason for hiding this comment

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

@ggazzo 👍

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the custom-user-status.list API endpoint to the new OpenAPI pattern, adding AJV-based JSON schema validation and improving API documentation with Swagger UI integration.

  • Refactored the endpoint to use the new chained route definition syntax with enhanced validation
  • Moved schema definitions from rest-typings to the actual endpoint implementation
  • Added comprehensive response validation and error handling

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/rest-typings/src/v1/customUserStatus.ts Removed schema definitions and validation logic that was moved to the endpoint implementation
packages/core-typings/src/Ajv.ts Added IUserStatus type to the schemas array for OpenAPI support
apps/meteor/app/api/server/v1/custom-user-status.ts Migrated to new OpenAPI pattern with comprehensive schema validation and type definitions
.changeset/sweet-terms-relax.md Added changeset documentation for the OpenAPI migration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Copy Markdown
Member

@cardoso cardoso left a comment

Choose a reason for hiding this comment

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

Sounds -> statuses . Finally a useful catch by copilot 😁

Copy link
Copy Markdown
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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/rest-typings/src/v1/customUserStatus.ts (1)

12-17: Contract mismatch — align name between server and typings

Server route "custom-user-status.update" enforces name: String (apps/meteor/app/api/server/v1/custom-user-status.ts) while rest-typings mark it optional (packages/rest-typings/src/v1/customUserStatus.ts). Align them.

  • Preferred fix (allow partial updates): change the server validation to make name optional:
    check(this.bodyParams, {
    _id: String,
    name: Match.Maybe(String),
    statusType: Match.Maybe(String),
    });

  • Alternate: make typings require name (remove the ?) if updates must always include name.

apps/meteor/app/api/server/v1/custom-user-status.ts (1)

175-185: Make name optional on update to match public typings.
Typings mark name optional; server currently requires it. Allow partial updates.

-			check(this.bodyParams, {
-				_id: String,
-				name: String,
-				statusType: Match.Maybe(String),
-			});
+			check(this.bodyParams, {
+				_id: String,
+				name: Match.Maybe(String),
+				statusType: Match.Maybe(String),
+			});
@@
-			const userStatusData = {
-				_id: this.bodyParams._id,
-				name: this.bodyParams.name,
-				statusType: this.bodyParams.statusType,
-			};
+			const userStatusData: { _id: string; name?: string; statusType?: string } = {
+				_id: this.bodyParams._id,
+				...(this.bodyParams.name !== undefined ? { name: this.bodyParams.name } : {}),
+				...(this.bodyParams.statusType !== undefined ? { statusType: this.bodyParams.statusType } : {}),
+			};
♻️ Duplicate comments (1)
apps/meteor/app/api/server/v1/custom-user-status.ts (1)

71-81: Replace “sounds” with “custom user statuses” in descriptions.
This was noted previously; apply the wording fix.

-					count: {
-						type: 'number',
-						description: 'The number of sounds returned in this response.',
-					},
+					count: { type: 'number', description: 'The number of custom user statuses returned in this response.' },
 					offset: {
 						type: 'number',
-						description: 'The number of sounds that were skipped in this response.',
+						description: 'The number of custom user statuses that were skipped in this response.',
 					},
 					total: {
 						type: 'number',
-						description: 'The total number of sounds that match the query.',
+						description: 'The total number of custom user statuses that match the query.',
 					},
🧹 Nitpick comments (3)
.changeset/sweet-terms-relax.md (1)

7-7: Polish the changeset summary for clarity and brevity.
Reads a bit long and misses a period. Suggest tightening and explicitly naming the endpoint path.

-Add OpenAPI support for the Rocket.Chat custom-user-status.list API endpoints by migrating to a modern chained route definition syntax and utilizing shared AJV schemas for validation to enhance API documentation and ensure type safety through response validation
+Add OpenAPI support for /v1/custom-user-status.list by migrating to chained route definitions and shared AJV schemas, improving docs and ensuring request/response type safety.
apps/meteor/app/api/server/v1/custom-user-status.ts (2)

20-47: Query param coercion: ensure Ajv is configured or widen schema.
count/offset arrive as strings via query params. If ajv is not using coerceTypes: true, validation will fail. Either confirm coercion is enabled in the shared ajv instance or accept string-or-number here.

-		count: {
-			type: 'number',
-			nullable: true,
-		},
-		offset: {
-			type: 'number',
-			nullable: true,
-		},
+		count: { oneOf: [{ type: 'number' }, { type: 'string' }], nullable: true },
+		offset: { oneOf: [{ type: 'number' }, { type: 'string' }], nullable: true },

158-161: Nit: fix error message grammar.

-				return API.v1.failure('The "customUserStatusId" params is required!');
+				return API.v1.failure('The "customUserStatusId" parameter is required!');
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e82cfaa and 2e7df16.

📒 Files selected for processing (4)
  • .changeset/sweet-terms-relax.md (1 hunks)
  • apps/meteor/app/api/server/v1/custom-user-status.ts (2 hunks)
  • packages/core-typings/src/Ajv.ts (1 hunks)
  • packages/rest-typings/src/v1/customUserStatus.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/meteor/app/api/server/v1/custom-user-status.ts (3)
packages/rest-typings/src/v1/Ajv.ts (3)
  • ajv (23-23)
  • validateBadRequestErrorResponse (46-46)
  • validateUnauthorizedErrorResponse (69-69)
apps/meteor/app/api/server/ApiClass.ts (1)
  • ExtractRoutesFromAPI (71-75)
packages/rest-typings/src/index.ts (1)
  • Endpoints (52-100)
🔇 Additional comments (2)
apps/meteor/app/api/server/v1/custom-user-status.ts (2)

209-214: Type export pattern looks good.
The ExtractRoutesFromAPI-based augmentation cleanly adds the list endpoint to public typings at build-time.


101-106: Incorrect — parseJsonQuery already sanitizes $-operators

parseJsonQuery (apps/meteor/app/api/server/helpers/parseJsonQuery.ts) calls clean(...) from apps/meteor/app/api/server/lib/cleanQuery.ts which removes keys starting with '$' unless they’re in the allow-list (defaults include ['$or','$and','$regex']) and validates the query, so merging ...query here does not allow arbitrary operator injection.

Likely an incorrect or invalid review comment.

Copy link
Copy Markdown
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: 0

♻️ Duplicate comments (1)
apps/meteor/app/api/server/v1/custom-user-status.ts (1)

70-81: Fixed “sounds” -> “custom user statuses” descriptions.

Accuracy issue from earlier review is resolved.

🧹 Nitpick comments (3)
apps/meteor/app/api/server/v1/custom-user-status.ts (3)

17-47: Use integer and non-negative constraints for pagination params.

count/offset are integral and should be >= 0. Tighten validation.

   count: {
-    type: 'number',
+    type: 'integer',
+    minimum: 0,
     nullable: true,
   },
   offset: {
-    type: 'number',
+    type: 'integer',
+    minimum: 0,
     nullable: true,
   },

57-91: 200-schema alignment with ICustomUserStatus looks good; add minItems.

Add minItems: 0 to statuses array for completeness.

   statuses: {
     type: 'array',
+    minItems: 0,
     items: {
       $ref: '#/components/schemas/ICustomUserStatus',
     },
   },

209-214: Avoid type-name collision with rest-typings’ CustomUserStatusEndpoints.

This file exports CustomUserStatusEndpoints, which likely duplicates the name from rest-typings and can confuse imports/IDE tooling. Prefer a distinct local name.

-export type CustomUserStatusEndpoints = ExtractRoutesFromAPI<typeof customUserStatusEndpoints>;
+export type CustomUserStatusListEndpoints = ExtractRoutesFromAPI<typeof customUserStatusEndpoints>;

 declare module '@rocket.chat/rest-typings' {
   // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
-  interface Endpoints extends CustomUserStatusEndpoints {}
+  interface Endpoints extends CustomUserStatusListEndpoints {}
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e7df16 and 82dbc07.

📒 Files selected for processing (2)
  • apps/meteor/app/api/server/v1/custom-user-status.ts (2 hunks)
  • packages/core-typings/src/Ajv.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core-typings/src/Ajv.ts
🧰 Additional context used
🧬 Code graph analysis (1)
apps/meteor/app/api/server/v1/custom-user-status.ts (4)
packages/rest-typings/src/v1/Ajv.ts (3)
  • ajv (23-23)
  • validateBadRequestErrorResponse (46-46)
  • validateUnauthorizedErrorResponse (69-69)
packages/models/src/index.ts (1)
  • CustomUserStatus (150-150)
apps/meteor/app/api/server/ApiClass.ts (1)
  • ExtractRoutesFromAPI (71-75)
packages/rest-typings/src/index.ts (1)
  • Endpoints (52-100)
⏰ 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: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🔇 Additional comments (5)
apps/meteor/app/api/server/v1/custom-user-status.ts (5)

1-4: Resolved type mismatch and imports look correct.

Good switch to ICustomUserStatus and proper AJV/typing utilities; this addresses prior “IUserStatus”/schema refs issues.

Also applies to: 11-11


107-114: LGTM on findPaginated usage and concurrent fetch.

Correct default sort and concurrent cursor/total retrieval.


115-121: Response shaping matches the declared 200 schema.

count/offset/total/success all align.


49-56: AJV coerceTypes is enabled for the custom-user-status validator — no change required.

packages/rest-typings/src/v1/customUserStatus.ts constructs Ajv({ coerceTypes: true }) and compiles the validator used by the endpoint, so query params like ?count=50 (string) will be coerced to numbers. (useDefaults is not enabled on that Ajv instance.)


95-106: No change required — parseJsonQuery returns a cleaned object and pagination enforces limits.

  • parseJsonQuery initializes query = {} and runs clean(...), which returns an object ({} fallback for non-objects), so spreading query is safe. (apps/meteor/app/api/server/helpers/parseJsonQuery.ts, apps/meteor/app/api/server/lib/cleanQuery.ts)
  • getPaginationItems clamps count to API_Upper_Count_Limit (fallback 100) and uses API_Default_Count (fallback 50); infinite count is only allowed when API_Allow_Infinite_Count=true. (apps/meteor/app/api/server/helpers/getPaginationItems.ts)

@ahmed-n-abdeltwab ahmed-n-abdeltwab force-pushed the feat/openapi-custom-user-status-list branch from 0a777cb to 2918e7f Compare February 19, 2026 11:31
Copy link
Copy Markdown
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.

🧹 Nitpick comments (3)
apps/meteor/app/api/server/v1/custom-user-status.ts (2)

45-46: required: [] is a no-op — consider removing it.

An empty required array has no effect and can be safely omitted.

♻️ Proposed cleanup
-    required: [],
     additionalProperties: false,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/api/server/v1/custom-user-status.ts` around lines 45 - 46,
Remove the no-op empty required array from the schema object (the line
`required: []`) so the schema only defines `additionalProperties: false`; locate
the schema block that currently contains both `required: []` and
`additionalProperties: false` and delete the `required: []` entry, leaving the
rest of the schema unchanged.

96-96: Remove the unnecessary type cast on queryParams.

The cast as Record<string, string | number | null | undefined> is not needed. While isCustomUserStatusListProps validates this.queryParams at runtime, it doesn't narrow the TypeScript type—queryParams remains Record<string, unknown> for type checking purposes. The getPaginationItems function accepts this type without issue, as evidenced by 59 other endpoints in the codebase calling it without any cast.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/api/server/v1/custom-user-status.ts` at line 96, Remove the
unnecessary type cast on this.queryParams when calling getPaginationItems:
simply pass this.queryParams directly to getPaginationItems (the runtime check
isCustomUserStatusListProps remains for validation) and delete the cast "as
Record<string, string | number | null | undefined>" so the call becomes
getPaginationItems(this.queryParams), matching other endpoints and keeping types
consistent.
.changeset/sweet-terms-relax.md (1)

2-5: Consider minor bump for @rocket.chat/rest-typings and @rocket.chat/core-typings.

Both packages gain new public type exports (CustomUserStatusEndpoints and the ICustomUserStatus addition to the AJV schema union). Per semver, adding a new exported symbol is a backwards-compatible feature addition — minor — rather than a bug fix (patch). This only matters if downstream consumers version these packages strictly.

♻️ Proposed change
 "@rocket.chat/meteor": patch
-"@rocket.chat/core-typings": patch
-"@rocket.chat/rest-typings": patch
+"@rocket.chat/core-typings": minor
+"@rocket.chat/rest-typings": minor
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/sweet-terms-relax.md around lines 2 - 5, The changeset
incorrectly marks `@rocket.chat/rest-typings` and `@rocket.chat/core-typings` as
patch bumps even though new public types were added; update the changeset so
both packages are bumped to minor instead of patch, referencing the added
exported symbols CustomUserStatusEndpoints and the ICustomUserStatus addition to
the AJV schema union so reviewers can verify the reason for the minor bump.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82dbc07 and 2918e7f.

📒 Files selected for processing (2)
  • .changeset/sweet-terms-relax.md
  • apps/meteor/app/api/server/v1/custom-user-status.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/v1/custom-user-status.ts
🧠 Learnings (1)
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.

Applied to files:

  • apps/meteor/app/api/server/v1/custom-user-status.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: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🔇 Additional comments (4)
apps/meteor/app/api/server/v1/custom-user-status.ts (4)

1-14: LGTM — past review concerns addressed.

ICustomUserStatus is now correctly imported and used throughout.


209-214: LGTM — CustomUserStatusEndpoints export and module augmentation follow the established pattern correctly.


62-90: No action required. The response object is correctly formed and will pass validation.

The API.v1.success() method (ApiClass.ts line 271) only adds success: true to the provided payload object. The endpoint returns API.v1.success({ statuses, count, offset, total }), which produces { statuses, count, offset, total, success: true } — exactly matching the schema's required fields ['success', 'statuses', 'count', 'offset', 'total'] with no additional properties. Runtime AJV validation will succeed.


101-105: Remove this comment: The alleged NoSQL injection does not exist by default.

The query parameter is only parsed when the environment variable ALLOW_UNSAFE_QUERY_AND_FIELDS_API_PARAMS is explicitly set to 'TRUE'. By default, this feature is disabled and the query remains an empty object. When enabled, parseJsonQuery() sanitizes the parsed query using the clean() function, which removes all $-prefixed operators except $or, $and, and $regex. While the code explicitly marks this behavior as deprecated (with security warnings about data exposure), it is not an unmitigated vulnerability—it is a gated, sanitized, and intentionally deprecated feature that requires explicit opt-in via environment variable.

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

Nitpick comments:
In @.changeset/sweet-terms-relax.md:
- Around line 2-5: The changeset incorrectly marks `@rocket.chat/rest-typings` and
`@rocket.chat/core-typings` as patch bumps even though new public types were
added; update the changeset so both packages are bumped to minor instead of
patch, referencing the added exported symbols CustomUserStatusEndpoints and the
ICustomUserStatus addition to the AJV schema union so reviewers can verify the
reason for the minor bump.

In `@apps/meteor/app/api/server/v1/custom-user-status.ts`:
- Around line 45-46: Remove the no-op empty required array from the schema
object (the line `required: []`) so the schema only defines
`additionalProperties: false`; locate the schema block that currently contains
both `required: []` and `additionalProperties: false` and delete the `required:
[]` entry, leaving the rest of the schema unchanged.
- Line 96: Remove the unnecessary type cast on this.queryParams when calling
getPaginationItems: simply pass this.queryParams directly to getPaginationItems
(the runtime check isCustomUserStatusListProps remains for validation) and
delete the cast "as Record<string, string | number | null | undefined>" so the
call becomes getPaginationItems(this.queryParams), matching other endpoints and
keeping types consistent.

@ahmed-n-abdeltwab ahmed-n-abdeltwab force-pushed the feat/openapi-custom-user-status-list branch from 7aff2ce to e06a963 Compare February 19, 2026 12:56
Copy link
Copy Markdown
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.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7aff2ce and bf628a6.

📒 Files selected for processing (1)
  • packages/core-typings/src/Ajv.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:

  • packages/core-typings/src/Ajv.ts
🧠 Learnings (3)
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.

Applied to files:

  • packages/core-typings/src/Ajv.ts
📚 Learning: 2025-10-06T20:32:23.658Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37152
File: packages/apps-engine/tests/test-data/utilities.ts:557-573
Timestamp: 2025-10-06T20:32:23.658Z
Learning: In packages/apps-engine/tests/test-data/utilities.ts, the field name `isSubscripbedViaBundle` in the `IMarketplaceSubscriptionInfo` type should not be flagged as a typo, as it may match the upstream API's field name.

Applied to files:

  • packages/core-typings/src/Ajv.ts
📚 Learning: 2025-12-18T15:18:31.688Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37773
File: apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx:24-34
Timestamp: 2025-12-18T15:18:31.688Z
Learning: In apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx, for internal call history items, the item.contactId is guaranteed to always match either the caller.id or callee.id in the call data, so the contact resolution in getContact will never result in undefined.

Applied to files:

  • packages/core-typings/src/Ajv.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: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🔇 Additional comments (1)
packages/core-typings/src/Ajv.ts (1)

13-16: No action needed.

IUserStatus does not appear in any endpoint schemas or REST type definitions, and there is no evidence it was previously included in the Ajv.ts union. The current code includes ICustomUserStatus, which extends IUserStatus, ensuring type compatibility through inheritance. Typia's schema generation handles this relationship automatically, so removing IUserStatus from the union (if it ever was there) poses no runtime risk.

Likely an incorrect or invalid review comment.

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

Duplicate comments:
In `@packages/core-typings/src/Ajv.ts`:
- Line 5: ICustomUserStatus has been correctly imported and added to the schemas
tuple and union extension; no code changes required—just verify the import
statement "import type { ICustomUserStatus } from './ICustomUserStatus';" exists
between ICustomSound and IInvite and that the union including ICustomUserStatus
is present in the schemas/union definitions so $ref resolution for the list
endpoint is covered.

@ahmed-n-abdeltwab
Copy link
Copy Markdown
Contributor Author

@cardoso 👍

@ahmed-n-abdeltwab
Copy link
Copy Markdown
Contributor Author

@ggazzo 👍

@ggazzo ggazzo added this to the 8.3.0 milestone Feb 23, 2026
@ggazzo
Copy link
Copy Markdown
Member

ggazzo commented Feb 23, 2026

/jira ARCH-1935

ahmed-n-abdeltwab and others added 2 commits February 23, 2026 17:39
…ndpoints by migrating to a modern chained route definition syntax and utilizing shared AJV schemas for validation to enhance API documentation and ensure type safety through response validation
@ggazzo ggazzo force-pushed the feat/openapi-custom-user-status-list branch from bf628a6 to ed41fa2 Compare February 23, 2026 20:40
@ggazzo ggazzo changed the title feat: Add OpenAPI Support to custom-user-status.list API chore: Add OpenAPI Support to custom-user-status.list API Feb 23, 2026
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.

5 participants