RocketChat/Rocket.Chat · error · Meteor.Error

invalid-params

invalid-params

Error message

validatorFunc.errors?.map((error: any) => error.message).join('\n ')

What it means

The validated REST layer (API.v1.get/post/... in ApiClass) runs each route's ajv validator — validateParams as a function or a per-HTTP-method map — over queryParams for GET and bodyParams for other methods. When validation fails it throws invalid-params with all ajv error messages joined by newlines, so the message enumerates exactly which properties failed which keywords.

Source

Thrown at apps/meteor/server/api/ApiClass.ts:905

						let result;

						const connection = { ...generateConnection(this.requestIp, this.request.headers), token: this.token };
						this.connection = connection;

						try {
							if (options.deprecation) {
								parseDeprecation(this, options.deprecation);
							}

							await api.enforceRateLimit(objectForRateLimitMatch, this.request, this.response, this.userId);

							if (_options.validateParams) {
								const requestMethod = this.request.method as Method;
								const validatorFunc =
									typeof _options.validateParams === 'function' ? _options.validateParams : _options.validateParams[requestMethod];

								if (validatorFunc && !validatorFunc(requestMethod === 'GET' ? this.queryParams : this.bodyParams)) {
									throw new Meteor.Error('invalid-params', validatorFunc.errors?.map((error: any) => error.message).join('\n '));
								}
							}
							if (
								this.userId &&
								(await api.processTwoFactor({
									userId: this.userId,
									request: this.request,
									options: _options,
									connection: connection as unknown as IMethodConnection,
								}))
							) {
								this.twoFactorChecked = true;
							}

							this.parseJsonQuery = () => api.parseJsonQuery(this);

							if (options.applyMeteorContext) {
								const invocation = APIClass.createMeteorInvocation(connection, this.userId, this.token);

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Read the joined ajv messages in the error text — they name the failing property and keyword (required, type, additionalProperties, etc.).
  2. Compare the payload against the route's schema in @rocket.chat/rest-typings (or the REST API docs) and fix mismatches.
  3. Send native JSON types (numbers as numbers), drop unknown fields, and include all required ones.
  4. After a server upgrade, re-test integrations — schema changes surface here.

Example fix

// before — misspelled field, string count
api.post('/v1/users.create', { username: 'a', email: 'a@b.c', passwrd: 'x', count: '5' });

// after
api.post('/v1/users.create', { username: 'a', email: 'a@b.c', password: 'x' });
Defensive patterns

Strategy: validation

Validate before calling

// client-side pre-validation against the same ajv schema the server uses
import Ajv from 'ajv';
const validate = new Ajv({ allErrors: true }).compile(schemaForRoute); // from @rocket.chat/rest-typings
if (!validate(payload)) {
	throw new Error(validate.errors?.map((e) => e.message).join('\n'));
}

Type guard

const isShape = <T>(validate: (x: unknown) => boolean, payload: unknown): payload is T => validate(payload);

Try / catch

try {
	await api.post('/v1/users.create', payload);
} catch (e: any) {
	if (e?.error === 'invalid-params') {
		// e.message lists each failing ajv keyword — fix the named fields and retry
	}
	throw e;
}

Prevention

When it happens

Trigger: Sending a REST request whose body or query fails the route's ajv schema: missing required properties, wrong types (e.g. count as string '50'), or extra properties when the schema sets additionalProperties: false.

Common situations: Client library older than the server's @rocket.chat/rest-typings schemas, integrations sending stringified numbers/booleans, renamed or deprecated fields, wrong payload casing.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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