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
- Read the joined ajv messages in the error text — they name the failing property and keyword (required, type, additionalProperties, etc.).
- Compare the payload against the route's schema in @rocket.chat/rest-typings (or the REST API docs) and fix mismatches.
- Send native JSON types (numbers as numbers), drop unknown fields, and include all required ones.
- 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
- Generate/derive clients from the server's REST typings so payloads always match current schemas
- Send native JSON types — numbers and booleans, not strings
- Run contract tests against schemas after server upgrades
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
- Type not supported
- error-user-param-not-provided
- error-users-params-not-provided
- error-invalid-sort
- error-invalid-fields
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/1f50808283c84c18.
Report an issue: GitHub.