RocketChat/Rocket.Chat · error · Meteor.Error
error-user-param-not-provided
error-user-param-not-provided
Error message
The required "userId" or "username" param was not provided
What it means
getUserFromParams is the shared resolver for REST endpoints that reference a user; it requires at least one non-blank userId, username or user param (values are .trim()ed, so whitespace-only counts as missing). When none is provided it throws error-user-param-not-provided; the sibling error-invalid-user covers values that are provided but match no user.
Source
Thrown at apps/meteor/server/api/lib/getUserFromParams.ts:31
full?: T,
): Promise<
T extends true
? IUser
: Pick<IUser, '_id' | 'username' | 'name' | 'status' | 'statusDefault' | 'statusText' | 'statusSource' | 'statusExpiresAt' | 'roles'>
> {
let user;
const projection = full
? {}
: { username: 1, name: 1, status: 1, statusDefault: 1, statusText: 1, statusSource: 1, statusExpiresAt: 1, roles: 1 };
if (params.userId?.trim()) {
user = await Users.findOneById(params.userId, { projection });
} else if (params.username?.trim()) {
user = await Users.findOneByUsernameIgnoringCase(params.username, { projection });
} else if (params.user?.trim()) {
user = await Users.findOneByUsernameIgnoringCase(params.user, { projection });
} else {
throw new Meteor.Error('error-user-param-not-provided', 'The required "userId" or "username" param was not provided');
}
if (!user) {
throw new Meteor.Error('error-invalid-user', 'The required "userId" or "username" param provided does not match any users');
}
return user;
}
export async function getUserListFromParams(params: {
userId?: string;
username?: string;
user?: string;
userIds?: string[];
usernames?: string[];
}): Promise<Pick<IUser, '_id' | 'username'>[]> {
// if params.userId is provided, include it as well
const soleUser = params.userId || params.username || params.user;View on GitHub (pinned to b2c16d5842)
Solutions
- Pass userId or username as a non-empty string in the query/body.
- Trim inputs client-side and omit the parameter entirely when empty rather than sending blank values.
- Double-check the accepted param names (userId, username, user) against the endpoint docs.
Example fix
// before
api.get('/v1/users.info', { params: { user: ' ' } }); // whitespace-only
// after
api.get('/v1/users.info', { params: { username: 'rocket.cat' } }); Defensive patterns
Strategy: validation
Validate before calling
const ident = params.userId?.trim() || params.username?.trim() || params.user?.trim();
if (!ident) {
// do not call the endpoint: require userId or username from the caller
} Type guard
function hasUserIdentifier(p: { userId?: string; username?: string; user?: string }): boolean {
return Boolean(p.userId?.trim() || p.username?.trim() || p.user?.trim());
} Try / catch
try {
await api.get('/v1/users.info', { params });
} catch (e: any) {
if (e?.error === 'error-user-param-not-provided') {
// prompt for/attach userId or username, then retry
}
throw e;
} Prevention
- Omit empty query params instead of sending blank strings
- Trim user input before building query strings
- Use the exact param names the endpoint accepts (userId, username, user)
When it happens
Trigger: Calling user-scoped REST routes (users.info, users.getAvatar, etc.) with none of userId/username/user in the query or body — e.g. dynamically built queries that end up with empty strings, blank form fields, or misspelled param names (user_name instead of username).
Common situations: Clients building query strings from optional inputs without dropping empties, typos in param names, whitespace from copy-paste.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- error-roomid-param-not-provided
- The "customFields" query parameter must be a valid JSON.
- invalid-chart-name
- error-roomId-param-invalid
- error-invalid-param
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/a395e9e0316150e8.
Report an issue: GitHub.