{"record":{"id":"89dc7920082443bb","repo":"theonedev/onedev","slug":"invalid-url","errorCode":null,"errorMessage":"Invalid url: ","messagePattern":"Invalid url: ","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-plugin/server-plugin-import-url/src/main/java/io/onedev/server/plugin/imports/url/ImportServer.java","lineNumber":103,"sourceCode":"\t\tif (StringUtils.isNotBlank(hostAndPath)) {\n\t\t\tString path = StringUtils.stripEnd(StringUtils.substringAfter(hostAndPath, \"/\"), \"/\");\n\t\t\tif (StringUtils.isNotBlank(path)) {\n\t\t\t\tif (path.endsWith(\".git\"))\n\t\t\t\t\tpath = path.substring(0, path.length()-\".git\".length());\n\t\t\t\treturn path;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\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)","sourceCodeStart":85,"sourceCodeEnd":121,"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#L85-L121","documentation":"Thrown by the generic URL importer when it cannot determine which OneDev project path to import into: neither an explicit project path was configured nor could one be derived from the source URL. deriveProjectPath failed to parse a sensible project path out of the given URL, so the importer rejects the URL as invalid.","triggerScenarios":"Calling importProject with a URL from which deriveProjectPath returns null — e.g. a URL that is not a recognizable git repository URL (missing .git suffix pattern, bare domain, malformed path), while the 'Project Path' field on the import form is left empty.","commonSituations":"Pasting a web page URL (e.g. a GitHub PR or project homepage) instead of the clone URL; URL with unusual port/path shape; leaving the target project field blank and importing from a generic http(s) file URL.","solutions":["Set the 'Project Path' field explicitly in the import form so derivation is skipped.","Use the repository clone URL (e.g. ending in .git) rather than a webpage URL.","Normalize the URL (remove query strings/fragments) and retry.","Check the plugin's deriveProjectPath rules to see what URL shapes are supported."],"exampleFix":"// before\nurl: https://github.com/acme/widget   // homepage, project path empty\n\n// after: clone URL from which path is derivable, or set project path\nurl: https://github.com/acme/widget.git\nprojectPath: acme/widget","handlingStrategy":"validation","validationCode":"// validate the URL before passing to the importer\nString url = getUrl();\nif (url == null || !url.matches(\"^https?://[^/]+/.+\"))\n    throw new IllegalArgumentException(\"URL not importable: \" + url);\nif (getProject() == null && deriveProjectPath(url) == null)\n    throw new IllegalArgumentException(\"Cannot derive project path from url; set project path explicitly\");","typeGuard":null,"tryCatchPattern":"try { importServer.importProject(...); } catch (ExplicitException e) { logger.error(\"Bad import URL: {}\", e.getMessage()); }","preventionTips":["Provide the target project path explicitly instead of relying on URL derivation.","Use canonical repository clone URLs (.git) rather than web pages.","Strip query strings and fragments from URLs before importing."],"tags":["import","url","validation","git"],"backgroundTag":"invalid-url-format","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}