theonedev/onedev · error · RuntimeException

internal error

Error message

internal error

What it means

PypiPackPanel.onInitialize parses the configured server URL with new URL(...) and wraps MalformedURLException in a RuntimeException. It means the OneDev server URL configured for display of pip usage instructions is malformed (no protocol, bad syntax).

Source

Thrown at server-plugin/server-plugin-pack-pypi/src/main/java/io/onedev/server/plugin/pack/pypi/PypiPackPanel.java:44

public class PypiPackPanel extends GenericPanel<Pack> {
	
	public PypiPackPanel(String id, IModel<Pack> model) {
		super(id, model);
	}

	@Override
	protected void onInitialize() {
		super.onInitialize();

		var serverUrl = getServerUrl();
		String protocol;
		String host;
		try {
			var url = new URL(serverUrl);
			 protocol = url.getProtocol();
			 host = url.getHost();
		} catch (MalformedURLException e) {
			throw new RuntimeException(e);
		}
		var canAccessAnonymously = SecurityUtils.asAnonymous().isPermitted(
				new ProjectPermission(getPack().getProject(), new ReadPack()));
		var authPart = canAccessAnonymously ? "" : "<OneDev_account_name>:<OneDev_password>@";
		var indexUrl = protocol + "://" + authPart + UrlUtils.getServer(serverUrl) 
				+ "/" + getPack().getProject().getPath() + "/~" + PypiPackHandler.HANDLER_ID + "/simple/";
		add(new WebMarkupContainer("readPermissionNote").setVisible(!canAccessAnonymously));
		var installCmd = "$ python3 -m pip install --extra-index-url " + indexUrl;
		if (protocol.equals("http"))
			installCmd += " --trusted-host " + host;
		installCmd += " " + getPack().getName() + "==" + getPack().getVersion();
		add(new Label("install", installCmd));

		indexUrl = protocol + "://@job_token@:@secret:access-token@@@" + UrlUtils.getServer(serverUrl)
				+ "/" + getPack().getProject().getPath() + "/~" + PypiPackHandler.HANDLER_ID + "/simple/";
		var jobCommands = "" +
				"# " + _T("Use job token to tell OneDev the build using the package") + "\n" +
				"# " + _T("Job secret 'access-token' should be defined in project build setting as an access token with package read permission") + "\n\n" +

View on GitHub (pinned to d44925c47c)

Solutions

  1. Fix the server URL in Administration > System Setting so it is a full absolute URL like https://onedev.example.com
  2. Include the http:// or https:// scheme explicitly
  3. Reload the package page to confirm instructions render

Example fix

// before
String serverUrl = "localhost:8080";
// after
String serverUrl = "https://localhost:8080";
Defensive patterns

Strategy: validation

Validate before calling

function validateServerUrl(url) {
  try { new java.net.URL(url); return true; } catch (e) { return false; }
}
// only proceed when validateServerUrl(serverUrl) is true and starts with http(s)://

Type guard

function isValidUrl(u) { try { const p = new URL(u); return p.protocol === 'http:' || p.protocol === 'https:'; } catch { return false; } }

Try / catch

try { renderPanel(); } catch (RuntimeException e) { if (e.getCause() instanceof MalformedURLException) showConfigWarning('Fix server URL in system settings'); else throw e; }

Prevention

When it happens

Trigger: The server URL in OneDev system settings (or the value passed to the panel) is empty, missing scheme, or otherwise not a valid absolute URL when the PyPI package page is rendered.

Common situations: Admin set server url to 'localhost:8080' without http(s):// in admin settings; placeholder not replaced; trailing typo in the URL after a server migration.

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


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/4846db7705cafe37. Report an issue: GitHub.