RocketChat/Rocket.Chat · error · Meteor.Error

error-param-not-provided

error-param-not-provided

Error message

Query param "role" is required

What it means

Thrown by GET /api/v1/roles.getUsersInRole (requires access-permissions) when the `role` query param is missing. The route's AJV query schema deliberately leaves `role` optional, so schema validation passes and the handler itself enforces the requirement — calling the endpoint bare, or with only pagination params, produces this error-param-not-provided.

Solutions

  1. Always include role — GET /api/v1/roles.getUsersInRole?role=<role _id>
  2. Remember this endpoint wants the role's _id, not its display name (see error-invalid-roleId)
  3. Add a client-side assert that the role param is a non-empty string before firing the request

Example fix

// before
const qs = new URLSearchParams({ offset: '0', ...(roomId && { roomId }) }); // role forgotten

// after
if (!role) throw new Error('role is required');
const qs = new URLSearchParams({ role, offset: '0', ...(roomId && { roomId }) });
Defensive patterns

Strategy: validation

Validate before calling

if (typeof role !== 'string' || role.length === 0) {
  throw new Error('roles.getUsersInRole requires a non-empty role query param');
}
await sdk.get('roles.getUsersInRole', { role, ...(roomId && { roomId }) });

Type guard

const hasRoleQueryParam = (q: Record<string, unknown>): q is { role: string } =>
  typeof q.role === 'string' && q.role.length > 0;

Try / catch

catch 'error-param-not-provided' and fail loudly at the call site — this is a client bug (missing/misspelled param), not a server state; fix the param construction instead of retrying.

Prevention

When it happens

Trigger: GET /api/v1/roles.getUsersInRole with no role param; passing the role in the body of a GET; typo'ing the param name (roles=, roleId=) so `role` stays undefined; building query strings conditionally and skipping the role clause.

Common situations: Optional-chaining bugs in client code (params.role ?? undefined sent as nothing); copied curl commands with the role value accidentally deleted; API wrappers that drop falsy params silently.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/54711f9b7a238092. Report an issue: GitHub.

Appendix: source

Thrown at apps/meteor/server/api/v1/roles.ts:190

				401: validateUnauthorizedErrorResponse,
				403: validateForbiddenErrorResponse,
			},
		},
		async function action() {
			const { roomId, role } = this.queryParams;
			const { offset, count = 50 } = await getPaginationItems(this.queryParams);

			const projection = {
				name: 1,
				username: 1,
				emails: 1,
				avatarETag: 1,
				createdAt: 1,
				_updatedAt: 1,
			};

			if (!role) {
				throw new Meteor.Error('error-param-not-provided', 'Query param "role" is required');
			}
			if (roomId && !(await hasPermissionAsync(this.user, 'view-other-user-channels'))) {
				throw new Meteor.Error('error-not-allowed', 'Not allowed');
			}

			const options = { projection: { _id: 1 } };
			const roleData = await Roles.findOneById<Pick<IRole, '_id'>>(role, options);

			if (!roleData) {
				throw new Meteor.Error('error-invalid-roleId');
			}

			const { cursor, totalCount } = await getUsersInRolePaginated(roleData._id, roomId, {
				limit: count,
				sort: { username: 1 },
				skip: offset,
				projection,
			});

View on GitHub (pinned to b2c16d5842)