SonarSource/sonarqube · error · IllegalArgumentException
Invalid GitHub URL
Error message
Invalid GitHub URL
What it means
After confirming the scheme is http/https, checkApiEndpoint() calls isValidGitHubUrl() which inspects the URI's host and path; if they don't look like a valid GitHub/GHE endpoint, this IllegalArgumentException is thrown. The scheme was fine but the URL's host/path structure is rejected.
Source
Thrown at server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationClientImpl.java:166
}
@Override
public void checkApiEndpoint(GithubAppConfiguration githubAppConfiguration) {
if (StringUtils.isBlank(githubAppConfiguration.getApiEndpoint())) {
throw new IllegalArgumentException("Missing URL");
}
URI apiEndpoint;
try {
apiEndpoint = URI.create(githubAppConfiguration.getApiEndpoint());
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid URL, " + e.getMessage());
}
if (!"http".equalsIgnoreCase(apiEndpoint.getScheme()) && !"https".equalsIgnoreCase(apiEndpoint.getScheme())) {
throw new IllegalArgumentException("Only http and https schemes are supported");
} else if (!isValidGitHubUrl(apiEndpoint)) {
throw new IllegalArgumentException("Invalid GitHub URL");
}
}
private static boolean isValidGitHubUrl(URI apiEndpoint) {
String host = apiEndpoint.getHost();
String path = apiEndpoint.getPath();
if (host == null) {
return false;
}
String lowerCaseHost = host.toLowerCase(Locale.ENGLISH);
// GitHub.com (official public GitHub)
if ("api.github.com".equals(lowerCaseHost)) {
return true;
}
// GitHub Enterprise Server - standard format: https://github.company.com/api/v3/
if (path != null && path.toLowerCase(Locale.ENGLISH).startsWith("/api/v3")) {View on GitHub (pinned to 184c821202)
Solutions
- Use the exact documented endpoints: https://api.github.com/ for GitHub.com or https://<ghe-host>/api/v3/ for GitHub Enterprise
- Check that the URL has a non-empty host
- Verify no typos or extra characters in the configured api endpoint
Example fix
// before
.setApiEndpoint("https:///api/v3")
// after
.setApiEndpoint("https://ghe.mycompany.com/api/v3") Defensive patterns
Strategy: validation
Validate before calling
URI uri = URI.create(apiEndpoint);
if (uri.getHost() == null || uri.getHost().isEmpty()) {
throw new IllegalArgumentException("GitHub endpoint URL must include a host");
} Type guard
static boolean looksLikeGitHubUrl(URI uri) {
return uri.getHost() != null && !uri.getHost().isEmpty();
} Try / catch
try {
githubApplicationClient.validateConfig(githubAppConfiguration);
} catch (IllegalArgumentException e) {
if ("Invalid GitHub URL".equals(e.getMessage())) {
// prompt user to fix the host portion of the endpoint
}
} Prevention
- Use the documented endpoints verbatim: https://api.github.com/ and https://<ghe-host>/api/v3/
- Test the URL in a browser/curl before configuring
- Beware of copy-paste artifacts (missing host, stray whitespace, double slashes)
When it happens
Trigger: Calling checkApiEndpoint (via validateConfig or findMissingAppPermissions) with an http/https URL whose host or path fails isValidGitHubUrl, e.g. 'https:///api' with empty host or a malformed GitHub endpoint path.
Common situations: GitHub Enterprise URL missing host ('https:///api/v3'); trailing garbage or typo in host; URL with no path where a path is expected for GHE; misconfigured sonar.auth.github.apiUrl for GitHub Enterprise.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- Only http and https schemes are supported
- url must start with http:// or https://
- Missing URL
- Invalid URL, %s
- Missing permissions; permission granted on %s
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/e248615ba1b695f4.
Report an issue: GitHub.