actualbudget/actual · error
cannot-find-user-to-update
cannot-find-user-to-update
Error message
Cannot find user ${userName} to update What it means
PATCH /users looks up the target account with `UserService.getUserById(id)`. If no user matches the supplied `id`, the handler responds 400 with reason 'cannot-find-user-to-update' and a message naming the username from the request. The endpoint refuses to update non-existent users.
Source
Thrown at packages/sync-server/src/app-admin.js:132
reason: `${!userName ? 'user-cant-be-empty' : 'role-cant-be-empty'}`,
details: `${!userName ? 'Username' : 'Role'} cannot be empty`,
});
return;
}
const roleIdFromDb = UserService.validateRole(role);
if (!roleIdFromDb) {
res.status(400).send({
status: 'error',
reason: 'role-does-not-exists',
details: 'Selected role does not exist',
});
return;
}
const userIdInDb = UserService.getUserById(id);
if (!userIdInDb) {
res.status(400).send({
status: 'error',
reason: 'cannot-find-user-to-update',
details: `Cannot find user ${userName} to update`,
});
return;
}
UserService.updateUserWithRole(
userIdInDb,
userName,
displayName || null,
enabled ? 1 : 0,
role,
);
res.status(200).send({ status: 'ok', data: { id: userIdInDb } });
});
View on GitHub (pinned to d4334cb6e6)
Solutions
- Fetch the current user list via the admin API and use the exact id returned for that username.
- Verify you are pointing at the same server/environment the id came from.
- If the user was deleted, recreate it via POST /users instead of updating.
- Log the id being sent and compare its length/format to a known-good user id (uuid).
Example fix
// before
await patchUser({ id: 'abc123', userName: 'jane', role: 'admin' }); // stale id
// after
const users = await listUsers();
const jane = users.find(u => u.user_name === 'jane');
await patchUser({ id: jane.id, userName: 'jane', role: 'admin' }); Defensive patterns
Strategy: validation
Validate before calling
const users = await listUsers(); // admin API
const target = users.find(u => u.user_name === userName);
if (!target) throw new Error(`User ${userName} not found on this server`);
// then PATCH with target.id Try / catch
try {
await patchUser({ id, userName, role });
} catch (e) {
if (e.status === 400 && e.reason === 'cannot-find-user-to-update') {
// refresh the user list and retry with a resolved id
const fresh = await listUsers();
const u = fresh.find(x => x.user_name === userName);
if (u) await patchUser({ id: u.id, userName, role });
} else throw e;
} Prevention
- Resolve ids from a fresh server list rather than cached UI state.
- Never hand-type or truncate user uuids.
- Confirm environment (staging vs production) before batch updates.
- After deleting users, purge their ids from local caches.
When it happens
Trigger: PATCH /users (admin session) with an id that does not exist in the users table — a deleted user, a truncated/typo'd id, an id from a different server's database, or an id from a file row mistakenly used as a user id.
Common situations: Stale admin UI caches holding ids of users deleted elsewhere; environment mismatch (staging id used against production); copy/paste dropping characters from the uuid; migrations referencing ids that were never imported.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
AI-assisted analysis of actualbudget/actual@d4334cb6e6 (2026-08-29).
Data as JSON: /api/errors/b3630330bc50ee84.
Report an issue: GitHub.