{"record":{"id":"58aa5ffb67df85f4","repo":"theonedev/onedev","slug":"import-target-already-exists-you-need-to-have-pro-58aa5f","errorCode":null,"errorMessage":"Import target already exists. You need to have project management privilege over it","messagePattern":"Import target already exists\\. You need to have project management privilege over it","errorType":"exception","errorClass":"UnauthorizedException","httpStatus":null,"severity":"error","filePath":"server-plugin/server-plugin-import-url/src/main/java/io/onedev/server/plugin/imports/url/ImportServer.java","lineNumber":113,"sourceCode":"\t\n\tTaskResult importProject(@Nullable String parentProjectPath, boolean dryRun, TaskLogger logger) {\n\t\treturn OneDev.getInstance(TransactionService.class).call(() -> {\n\t\t\ttry {\n\t\t\t\tString projectPath = getProject();\n\t\t\t\tif (projectPath == null)\n\t\t\t\t\tprojectPath = deriveProjectPath(getUrl());\n\t\t\t\tif (projectPath == null)\n\t\t\t\t\tthrow new ExplicitException(\"Invalid url: \" + getUrl());\n\t\t\t\t\n\t\t\t\tif (parentProjectPath != null)\n\t\t\t\t\tprojectPath = parentProjectPath + \"/\" + projectPath;\n\n\t\t\t\tlogger.log(\"Importing from '\" + getUrl() + \"' to '\" + projectPath + \"'...\");\n\n\t\t\t\tProject project = getProjectService().setup(SecurityUtils.getSubject(), projectPath);\n\n\t\t\t\tif (!project.isNew() && !SecurityUtils.canManageProject(project)) {\n\t\t\t\t\tthrow new UnauthorizedException(\"Import target already exists. \" +\n\t\t\t\t\t\t\t\"You need to have project management privilege over it\");\n\t\t\t\t}\n\n\t\t\t\tif (project.isNew() || project.getDefaultBranch() == null) {\n\t\t\t\t\tlogger.log(\"Cloning code...\");\n\n\t\t\t\t\tURIBuilder builder = new URIBuilder(getUrl());\n\t\t\t\t\tif (authentication != null)\n\t\t\t\t\t\tbuilder.setUserInfo(authentication.getUserName(), authentication.getPassword());\n\n\t\t\t\t\tSecretMasker.push(text -> {\n\t\t\t\t\t\tif (authentication != null)\n\t\t\t\t\t\t\treturn Strings.CS.replace(text, authentication.getPassword(), \"******\");\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\treturn text;\n\t\t\t\t\t});\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (dryRun) {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-import-url/src/main/java/io/onedev/server/plugin/imports/url/ImportServer.java#L95-L131","documentation":"Thrown after getProjectService().setup(...) resolves (and possibly creates) the target project: if the project already existed and the current user does not have management privilege over it, the importer refuses to overwrite/import into it via UnauthorizedException. It protects existing projects from being clobbered by an import by users who merely have read/commit access.","triggerScenarios":"Importing a URL into a project path that already exists in OneDev, where the authenticated user is not a project manager of that existing project. Also occurs when SecurityUtils.canManageProject returns false due to group/role restrictions on the target path.","commonSituations":"A non-admin tries to import into a team project someone else created; import form auto-derived a project path that collides with an existing project; user's manage permission was revoked after a previous import.","solutions":["Ask a OneDev administrator to grant you Manage privilege on the target project.","Choose a different (non-existing) project path for the import.","Delete the existing project if it is unused and you have authority to do so.","Import under your own namespace where you automatically have management rights."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check before import\nProject project = OneDev.getInstance(ProjectService.class).findByPath(projectPath);\nif (project != null && !SecurityUtils.canManageProject(project))\n    throw new IllegalStateException(\"You lack manage privilege over existing project \" + projectPath);","typeGuard":null,"tryCatchPattern":"try { importServer.importProject(...); } catch (UnauthorizedException e) { logger.error(\"Import blocked: {}\", e.getMessage()); }","preventionTips":["Import into paths under your own namespace.","Verify manage permission on the target project beforehand.","Ask an admin to pre-grant privileges for team project imports."],"tags":["import","permissions","authorization","project-management"],"backgroundTag":"permission-denied","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"}