jellyfin/jellyfin · error · ResourceNotFoundException
User with UserId {authInfo.UserId} not found
Error message
User with UserId {authInfo.UserId} not found What it means
DeviceManager.ToDeviceInfo throws ResourceNotFoundException('User with UserId ... not found') when the Device record's UserId no longer resolves to a user via GetUserById. ToDeviceInfo builds a DeviceInfo including the LastUserName, so it must look up the user; a deleted user makes the lookup return null and the coalescing throw fires.
Source
Thrown at Jellyfin.Server.Implementations/Devices/DeviceManager.cs:254
/// <inheritdoc />
public bool CanAccessDevice(User user, string deviceId)
{
ArgumentNullException.ThrowIfNull(user);
ArgumentException.ThrowIfNullOrEmpty(deviceId);
if (user.HasPermission(PermissionKind.EnableAllDevices) || user.HasPermission(PermissionKind.IsAdministrator))
{
return true;
}
return user.GetPreference(PreferenceKind.EnabledDevices).Contains(deviceId, StringComparison.OrdinalIgnoreCase)
|| !GetCapabilities(deviceId).SupportsPersistentIdentifier;
}
private DeviceInfo ToDeviceInfo(Device authInfo, DeviceOptions? options = null)
{
var caps = GetCapabilities(authInfo.DeviceId);
var user = _userManager.GetUserById(authInfo.UserId) ?? throw new ResourceNotFoundException("User with UserId " + authInfo.UserId + " not found");
return new()
{
AppName = authInfo.AppName,
AppVersion = authInfo.AppVersion,
Id = authInfo.DeviceId,
LastUserId = authInfo.UserId,
LastUserName = user.Username,
Name = authInfo.DeviceName,
DateLastActivity = authInfo.DateLastActivity,
IconUrl = caps.IconUrl,
CustomName = options?.CustomName,
};
}
private DeviceOptionsDto ToDeviceOptionsDto(DeviceOptions options)
{
return new()View on GitHub (pinned to ae8723026d)
Solutions
- Clean up orphaned device rows whose UserId no longer exists, then retry the device listing.
- Re-add or re-map the referenced user, or delete the stale device entries via the admin UI/API before listing.
- If maintaining a custom DeviceManager, guard ToDeviceInfo to skip/filter devices whose user is missing.
Example fix
// before
var user = _userManager.GetUserById(authInfo.UserId)
?? throw new ResourceNotFoundException(...);
// after
var user = _userManager.GetUserById(authInfo.UserId);
if (user is null) return null; // filter orphaned devices upstream Defensive patterns
Strategy: validation
Validate before calling
// Before listing devices, prune orphans var users = (await client.GetUsersAsync()).Select(u => u.Id).ToHashSet(); var devices = (await client.GetDevicesAsync()).Where(d => users.Contains(d.UserId));
Type guard
bool UserExists(Guid id, HashSet<Guid> known) => known.Contains(id);
Try / catch
try { devices = await client.GetDevicesAsync(); }
catch (ResourceNotFoundException e) when (e.Message.Contains("User with UserId"))
{ await CleanupOrphanedDevices(); devices = await client.GetDevicesAsync(); } Prevention
- When deleting a user, also remove their device records.
- Audit device rows for stale UserIds after DB restores.
- In custom DeviceManagers, filter out devices whose user is missing.
When it happens
Trigger: Listing or fetching devices (GET /Devices) where one or more Device entries reference a UserId that was deleted. ToDeviceInfo is called while projecting each device, so a single stale device aborts the listing.
Common situations: Users deleted after their devices were registered; database restores that drop users but keep device rows; multi-server device imports carrying foreign user ids.
Related errors
- Password hash with id '{hash.Id}' is missing required 'itera
- Password hash with id '{hash.Id}' has invalid 'iterations' p
- User account has been disabled.
- User not found
- No user exists after initialization.
AI-assisted analysis of jellyfin/jellyfin@ae8723026d (2026-08-13).
Data as JSON: /api/errors/ecf2f97cc895e9ad.
Report an issue: GitHub.