jellyfin/jellyfin · error · InvalidOperationException

No user exists after initialization.

Error message

No user exists after initialization.

What it means

GetFirstUser throws InvalidOperationException('No user exists after initialization.') when _userManager.GetFirstUser() returns null even after InitializeAsync has run. This startup-wizard endpoint guarantees an initial admin user exists; the exception signals a broken user store where initialization did not create the expected first user. Marked Obsolete in favor of authentication endpoints.

Source

Thrown at Jellyfin.Api/Controllers/StartupController.cs:117

        settings.EnableRemoteAccess = startupRemoteAccessDto.EnableRemoteAccess;
        _config.SaveConfiguration(NetworkConfigurationStore.StoreKey, settings);
        return NoContent();
    }

    /// <summary>
    /// Gets the first user.
    /// </summary>
    /// <response code="200">Initial user retrieved.</response>
    /// <returns>The first user.</returns>
    [HttpGet("User")]
    [HttpGet("FirstUser", Name = "GetFirstUser_2")]
    [ProducesResponseType(StatusCodes.Status200OK)]
    [Obsolete("Use authentication endpoints")]
    public async Task<StartupUserDto> GetFirstUser()
    {
        // TODO: Remove this method when startup wizard no longer requires an existing user.
        await _userManager.InitializeAsync().ConfigureAwait(false);
        var user = _userManager.GetFirstUser() ?? throw new InvalidOperationException("No user exists after initialization.");
        return new StartupUserDto
        {
            Name = user.Username
        };
    }

    /// <summary>
    /// Sets the user name and password.
    /// </summary>
    /// <param name="startupUserDto">The DTO containing username and password.</param>
    /// <response code="204">Updated user name and password.</response>
    /// <returns>
    /// A <see cref="Task" /> that represents the asynchronous update operation.
    /// The task result contains a <see cref="NoContentResult"/> indicating success.
    /// </returns>
    [HttpPost("User")]
    [ProducesResponseType(StatusCodes.Status204NoContent)]
    public async Task<ActionResult> UpdateStartupUser([FromBody] StartupUserDto startupUserDto)

View on GitHub (pinned to ae8723026d)

Solutions

  1. Re-run the startup wizard to completion so the initial admin user is created, then retry.
  2. Inspect the Users table/repository to confirm initialization wrote a row; fix DB connectivity or permissions if writes failed.
  3. If using a custom user store, ensure InitializeAsync seeds a first user as the default implementation does.
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure a user exists before hitting the startup endpoint
var users = await client.GetUsersAsync();
if (users.Count == 0) { await RunStartupWizard(); }

Type guard

bool HasAnyUser(IEnumerable<UserDto> users) => users.Any();

Try / catch

try { var u = await client.GetFirstUserAsync(); }
catch (InvalidOperationException) { await RunStartupWizard(); /* then retry */ }

Prevention

When it happens

Trigger: Calling GET /Startup/User (or /Startup/FirstUser) on a server whose user repository is empty or corrupt after InitializeAsync, e.g. a fresh DB where the init wizard was interrupted or the schema migration left no users.

Common situations: First-run setups aborted mid-wizard; database restore that wiped the Users table; custom IUserManager implementations that don't seed an initial user; misconfigured database connection silently failing writes.

Related errors


AI-assisted analysis of jellyfin/jellyfin@ae8723026d (2026-08-13). Data as JSON: /api/errors/908659ca26c10772. Report an issue: GitHub.