RocketChat / RocketChat/Rocket.Chat

Fix schema inconsistencies in rooms.ts

Open Beginner friendly
#39,680 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

In packages/rest-typings/src/v1/rooms.ts, two inconsistencies exist between the TypeScript types and their corresponding AJV schemas in RoomsCreateDiscussionSchema and membersOrderedByRoleRolePropsSchema.

Expected Behavior

  • RoomsCreateDiscussionSchema should include the topic field to match the RoomsCreateDiscussionProps TypeScript type so clients sending topic have it correctly passed through.
  • membersOrderedByRoleRolePropsSchema should have type: 'object' at the root level, consistent with all other schemas in the file, so AJV correctly rejects non-object inputs.

Current Behavior

// topic declared in type but missing from schema
type RoomsCreateDiscussionProps = {
	...
	topic?: string; // exists in type
};

const RoomsCreateDiscussionSchema = {
	type: 'object',
	properties: {
		...
		reply: { type: 'string', nullable: true },
		// topic missing here — silently stripped by additionalProperties: false
	},
	required: ['prid', 't_name'],
	additionalProperties: false,
};

// missing type: 'object' at root
const membersOrderedByRoleRolePropsSchema = {
	// missing type: 'object'
	properties: { ... },
	oneOf: [{ required: ['roomId'] }, { required: ['roomName'] }],
	additionalProperties: false,
};

Steps to Reproduce

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

Additional Context

  • Every other schema in the file has type: 'object' at the root making the omission a clear inconsistency
  • additionalProperties: false actively strips topic from every request silently with no error
  • Both fixes are purely additive with no runtime behavior changes for any valid existing client

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open packages/rest-typings/src/v1/rooms.ts and compare RoomsCreateDiscussionProps with RoomsCreateDiscussionSchema, then inspect membersOrderedByRoleRolePropsSchema against the other schemas in the file. Add the missing schema definitions and verify that topic is accepted and non-object inputs are rejected as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.