Mintplex-Labs/anything-llm · warning
No valid user IDs provided.
Error message
No valid user IDs provided.
What it means
Returned by the workspace-users update endpoint when, after filtering `reqBody.userIds.map(Number)` against User.where({id:{in:...}}), zero users match. So every provided id was nonexistent or non-numeric (NaN matches nothing). Note two adjacent hazards: userIds omitted entirely makes `.map` throw (500), and this validation uses 404 for what is really a 400-class input problem.
Source
Thrown at server/endpoints/api/admin/index.js:638
const { workspaceSlug } = request.params;
const { userIds: _uids, reset = false } = reqBody(request);
const userIds = (
await User.where({ id: { in: _uids.map(Number) } })
).map((user) => user.id);
const workspace = await Workspace.get({ slug: String(workspaceSlug) });
const workspaceUsers = await Workspace.workspaceUsers(workspace.id);
if (!workspace) {
response.status(404).json({
success: false,
error: `Workspace ${workspaceSlug} not found`,
users: workspaceUsers,
});
return;
}
if (userIds.length === 0) {
response.status(404).json({
success: false,
error: `No valid user IDs provided.`,
users: workspaceUsers,
});
return;
}
// Reset all users in the workspace and add the new users as the only users in the workspace
if (reset) {
const { success, error } = await Workspace.updateUsers(
workspace.id,
userIds
);
return response.status(200).json({
success,
error,
users: await Workspace.workspaceUsers(workspace.id),
});View on GitHub (pinned to 3aec848f28)
Solutions
- Fetch the user list from the admin API first and send only existing integer ids: userIds:[1,2,3]
- Ensure the field is an array of numbers (or numeric strings) — never omit it, never send usernames
- Validate client-side that every entry passes Number.isInteger(Number(x))
Example fix
// before
{ userIds: ['sam', '2'] } // 'sam' -> NaN, so only id 2 matches; if none match -> 404
// after
const users = await getUsers();
const ids = ['sam','2'].map(Number).filter(Number.isInteger)
.filter(id => users.some(u => u.id === id));
if (ids.length === 0) throw new Error('no valid users');
{ userIds: ids } Defensive patterns
Strategy: validation
Validate before calling
function normalizeUserIds(ids, knownUsers) {
if (!Array.isArray(ids)) throw new TypeError('userIds must be an array');
const valid = ids.map(Number).filter(n => Number.isInteger(n));
const existing = valid.filter(n => knownUsers.some(u => u.id === n));
if (existing.length === 0) throw new Error('no valid user ids — nothing to do');
return existing;
} Type guard
function isUserIdsPayload(b) {
return Boolean(b) && Array.isArray(b.userIds) &&
b.userIds.length > 0 &&
b.userIds.every(x => Number.isInteger(Number(x)) && String(x).trim() !== '');
} Prevention
- Always send userIds as a non-empty array of integers matching existing users
- Fetch the admin users list first and map usernames to ids client-side
- Never omit userIds — the server .map()s it unguarded and a missing field becomes a 500
When it happens
Trigger: POST with userIds:[999999] (deleted users), userIds:['abc'] (non-numeric strings -> NaN), or ids valid in another environment but not this one. userIds undefined or not an array -> TypeError -> 500 instead.
Common situations: Hardcoded user id lists drifting after DB resets; passing usernames or usernames-as-strings instead of numeric ids; environment mismatch between staging and production user tables.
Related errors
- Workspace ${workspaceSlug} not found
- Invite not found or already disabled
- No text to predict on.
- Invalid password.
- Passwords do not match
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/24f3219a9d096a95.
Report an issue: GitHub.