theonedev/onedev · error · ExplicitException
Invalid url:
Error message
Invalid url:
What it means
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.
Source
Thrown at server-plugin/server-plugin-import-url/src/main/java/io/onedev/server/plugin/imports/url/ImportServer.java:103
if (StringUtils.isNotBlank(hostAndPath)) {
String path = StringUtils.stripEnd(StringUtils.substringAfter(hostAndPath, "/"), "/");
if (StringUtils.isNotBlank(path)) {
if (path.endsWith(".git"))
path = path.substring(0, path.length()-".git".length());
return path;
}
}
return null;
}
TaskResult importProject(@Nullable String parentProjectPath, boolean dryRun, TaskLogger logger) {
return OneDev.getInstance(TransactionService.class).call(() -> {
try {
String projectPath = getProject();
if (projectPath == null)
projectPath = deriveProjectPath(getUrl());
if (projectPath == null)
throw new ExplicitException("Invalid url: " + getUrl());
if (parentProjectPath != null)
projectPath = parentProjectPath + "/" + projectPath;
logger.log("Importing from '" + getUrl() + "' to '" + projectPath + "'...");
Project project = getProjectService().setup(SecurityUtils.getSubject(), projectPath);
if (!project.isNew() && !SecurityUtils.canManageProject(project)) {
throw new UnauthorizedException("Import target already exists. " +
"You need to have project management privilege over it");
}
if (project.isNew() || project.getDefaultBranch() == null) {
logger.log("Cloning code...");
URIBuilder builder = new URIBuilder(getUrl());
if (authentication != null)View on GitHub (pinned to d44925c47c)
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.
Example fix
// before url: https://github.com/acme/widget // homepage, project path empty // after: clone URL from which path is derivable, or set project path url: https://github.com/acme/widget.git projectPath: acme/widget
Defensive patterns
Strategy: validation
Validate before calling
// validate the URL before passing to the importer
String url = getUrl();
if (url == null || !url.matches("^https?://[^/]+/.+"))
throw new IllegalArgumentException("URL not importable: " + url);
if (getProject() == null && deriveProjectPath(url) == null)
throw new IllegalArgumentException("Cannot derive project path from url; set project path explicitly"); Try / catch
try { importServer.importProject(...); } catch (ExplicitException e) { logger.error("Bad import URL: {}", e.getMessage()); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- Invalid request path
- Error validating imported build spec (import project: %s, im
- Unable to find commit to import build spec (import project:
- Invalid commit id
- Ref name should start with refs/
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/89dc7920082443bb.
Report an issue: GitHub.