{"record":{"id":"e248615ba1b695f4","repo":"SonarSource/sonarqube","slug":"invalid-github-url","errorCode":null,"errorMessage":"Invalid GitHub URL","messagePattern":"Invalid GitHub URL","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationClientImpl.java","lineNumber":166,"sourceCode":"  }\n\n  @Override\n  public void checkApiEndpoint(GithubAppConfiguration githubAppConfiguration) {\n    if (StringUtils.isBlank(githubAppConfiguration.getApiEndpoint())) {\n      throw new IllegalArgumentException(\"Missing URL\");\n    }\n\n    URI apiEndpoint;\n    try {\n      apiEndpoint = URI.create(githubAppConfiguration.getApiEndpoint());\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(\"Invalid URL, \" + e.getMessage());\n    }\n\n    if (!\"http\".equalsIgnoreCase(apiEndpoint.getScheme()) && !\"https\".equalsIgnoreCase(apiEndpoint.getScheme())) {\n      throw new IllegalArgumentException(\"Only http and https schemes are supported\");\n    } else if (!isValidGitHubUrl(apiEndpoint)) {\n      throw new IllegalArgumentException(\"Invalid GitHub URL\");\n    }\n  }\n\n  private static boolean isValidGitHubUrl(URI apiEndpoint) {\n    String host = apiEndpoint.getHost();\n    String path = apiEndpoint.getPath();\n    if (host == null) {\n      return false;\n    }\n\n    String lowerCaseHost = host.toLowerCase(Locale.ENGLISH);\n    // GitHub.com (official public GitHub)\n    if (\"api.github.com\".equals(lowerCaseHost)) {\n      return true;\n    }\n\n    // GitHub Enterprise Server - standard format: https://github.company.com/api/v3/\n    if (path != null && path.toLowerCase(Locale.ENGLISH).startsWith(\"/api/v3\")) {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationClientImpl.java#L148-L184","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n.setApiEndpoint(\"https:///api/v3\")\n// after\n.setApiEndpoint(\"https://ghe.mycompany.com/api/v3\")","handlingStrategy":"validation","validationCode":"URI uri = URI.create(apiEndpoint);\nif (uri.getHost() == null || uri.getHost().isEmpty()) {\n  throw new IllegalArgumentException(\"GitHub endpoint URL must include a host\");\n}","typeGuard":"static boolean looksLikeGitHubUrl(URI uri) {\n  return uri.getHost() != null && !uri.getHost().isEmpty();\n}","tryCatchPattern":"try {\n  githubApplicationClient.validateConfig(githubAppConfiguration);\n} catch (IllegalArgumentException e) {\n  if (\"Invalid GitHub URL\".equals(e.getMessage())) {\n    // prompt user to fix the host portion of the endpoint\n  }\n}","preventionTips":["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)"],"tags":["github","configuration","url-validation","ghe"],"backgroundTag":"invalid-url","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}