{"record":{"id":"908659ca26c10772","repo":"jellyfin/jellyfin","slug":"no-user-exists-after-initialization","errorCode":null,"errorMessage":"No user exists after initialization.","messagePattern":"No user exists after initialization\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Jellyfin.Api/Controllers/StartupController.cs","lineNumber":117,"sourceCode":"        settings.EnableRemoteAccess = startupRemoteAccessDto.EnableRemoteAccess;\n        _config.SaveConfiguration(NetworkConfigurationStore.StoreKey, settings);\n        return NoContent();\n    }\n\n    /// <summary>\n    /// Gets the first user.\n    /// </summary>\n    /// <response code=\"200\">Initial user retrieved.</response>\n    /// <returns>The first user.</returns>\n    [HttpGet(\"User\")]\n    [HttpGet(\"FirstUser\", Name = \"GetFirstUser_2\")]\n    [ProducesResponseType(StatusCodes.Status200OK)]\n    [Obsolete(\"Use authentication endpoints\")]\n    public async Task<StartupUserDto> GetFirstUser()\n    {\n        // TODO: Remove this method when startup wizard no longer requires an existing user.\n        await _userManager.InitializeAsync().ConfigureAwait(false);\n        var user = _userManager.GetFirstUser() ?? throw new InvalidOperationException(\"No user exists after initialization.\");\n        return new StartupUserDto\n        {\n            Name = user.Username\n        };\n    }\n\n    /// <summary>\n    /// Sets the user name and password.\n    /// </summary>\n    /// <param name=\"startupUserDto\">The DTO containing username and password.</param>\n    /// <response code=\"204\">Updated user name and password.</response>\n    /// <returns>\n    /// A <see cref=\"Task\" /> that represents the asynchronous update operation.\n    /// The task result contains a <see cref=\"NoContentResult\"/> indicating success.\n    /// </returns>\n    [HttpPost(\"User\")]\n    [ProducesResponseType(StatusCodes.Status204NoContent)]\n    public async Task<ActionResult> UpdateStartupUser([FromBody] StartupUserDto startupUserDto)","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/jellyfin/jellyfin/blob/ae8723026d97b6d0f926638803edef338919b794/Jellyfin.Api/Controllers/StartupController.cs#L99-L135","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run the startup wizard to completion so the initial admin user is created, then retry.","Inspect the Users table/repository to confirm initialization wrote a row; fix DB connectivity or permissions if writes failed.","If using a custom user store, ensure InitializeAsync seeds a first user as the default implementation does."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure a user exists before hitting the startup endpoint\nvar users = await client.GetUsersAsync();\nif (users.Count == 0) { await RunStartupWizard(); }","typeGuard":"bool HasAnyUser(IEnumerable<UserDto> users) => users.Any();","tryCatchPattern":"try { var u = await client.GetFirstUserAsync(); }\ncatch (InvalidOperationException) { await RunStartupWizard(); /* then retry */ }","preventionTips":["Complete the startup wizard on first run.","Verify DB connectivity before relying on InitializeAsync.","For custom user stores, seed an initial admin user."],"tags":["startup","user-management","configuration"],"backgroundTag":null,"analyzedSha":"ae8723026d97b6d0f926638803edef338919b794","analyzedAt":"2026-08-13T10:43:30.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}