{"record":{"id":"2d0da3d7bf41c338","repo":"theonedev/onedev","slug":"server-not-set-up-yet-2d0da3","errorCode":null,"errorMessage":"Server not set up yet","messagePattern":"Server not set up yet","errorType":"console","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/commandhandler/ResetAdminPassword.java","lineNumber":71,"sourceCode":"\t\t\tSystem.exit(1);\n\t\t}\n\n\t\ttry {\n\t\t\tdoMaintenance(() -> {\n\t\t\t\tsessionFactoryService.start();\n\n\t\t\t\ttry (var conn = dataService.openConnection()) {\n\t\t\t\t\tcallWithTransaction(conn, () -> {\n\t\t\t\t\t\tdataService.checkDataVersion(conn, false);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t});\n\t\t\t\t} catch (SQLException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\n\t\t\t\tUser root = userService.get(User.ROOT_ID);\n\t\t\t\tif (root == null)\n\t\t\t\t\tthrow new ExplicitException(\"Server not set up yet\");\n\t\t\t\tString password = Bootstrap.command.getArgs()[0];\n\t\t\t\troot.setTwoFactorAuthentication(null);\n\t\t\t\troot.setPassword(passwordService.encryptPassword(password));\n\t\t\t\tuserService.update(root, null);\n\n\t\t\t\t// wait for a short period to have embedded db flushing data\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(1000);\n\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t}\n\n\t\t\t\tlogger.info(\"Password of user '\" + root.getName() + \"' has been reset\");\n\t\t\t\treturn null;\n\t\t\t});\n\t\t\tSystem.exit(0);\n\t\t} catch (ExplicitException e) {\n\t\t\tlogger.error(e.getMessage());","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/commandhandler/ResetAdminPassword.java#L53-L89","documentation":"The reset-admin-password command handler loads the root (admin) user by User.ROOT_ID and resets its password. If the root user record does not exist, the database has not been initialized/populated (setup never ran), so it throws 'Server not set up yet'.","triggerScenarios":"Running 'reset-admin-password <new-password>' against a OneDev database where the root user row is absent — i.e. before first-time setup completed or against a fresh/empty database.","commonSituations":"Pointing the command at the wrong data directory or wrong database; running it immediately after a fresh install before the setup wizard created the admin account; database restore that lacks the root user row.","solutions":["Ensure the server has completed initial setup (root user created) before running the command.","Point the command at the correct site directory / database containing existing data.","If the database was restored incompletely, restore the users table or re-run setup.","Check that the server process is stopped or compatible with the command's direct DB access requirements."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify root user exists before resetting password\nUser root = userService.get(User.ROOT_ID);\nif (root == null)\n    throw new IllegalStateException(\"Root user missing: complete setup first\");","typeGuard":null,"tryCatchPattern":"try {\n    new ResetAdminPassword(...).start();\n} catch (ExplicitException e) {\n    if (e.getMessage().contains(\"Server not set up yet\"))\n    logger.error(\"Database has no admin user; run initial setup first\");\n}","preventionTips":["Confirm the target database actually contains OneDev data before admin commands.","Double-check the site/data directory configured for the command.","After restoring a DB backup, verify the root user row exists before resetting its password."],"tags":["setup","server-command","database","admin-password"],"backgroundTag":"record-not-found","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}