{"record":{"id":"6639b255a40557f1","repo":"SonarSource/sonarqube","slug":"s-is-not-a-valid-url","errorCode":null,"errorMessage":"%s is not a valid url","messagePattern":"(.+?) is not a valid url","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/sonar-alm-client/src/main/java/org/sonar/alm/client/GenericApplicationHttpClient.java","lineNumber":220,"sourceCode":"    Request.Builder url = new Request.Builder().url(toAbsoluteEndPoint(appUrl, endPoint));\n    if (token != null) {\n      url.addHeader(devopsPlatformHeaders.getAuthorizationHeader(), token.getAuthorizationHeaderPrefix() + \" \" + token.getValue());\n      devopsPlatformHeaders.getApiVersion().ifPresent(apiVersion ->\n        url.addHeader(devopsPlatformHeaders.getApiVersionHeader().orElseThrow(), apiVersion)\n      );\n    }\n    extraHeaders.forEach(url::addHeader);\n    return url;\n  }\n\n  private static String toAbsoluteEndPoint(String host, String endPoint) {\n    if (endPoint.startsWith(\"http\")) {\n      return endPoint;\n    }\n    try {\n      return new URI(host + endPoint).toURL().toExternalForm();\n    } catch (URISyntaxException | IllegalArgumentException | MalformedURLException e) {\n      throw new IllegalArgumentException(String.format(\"%s is not a valid url\", host + endPoint));\n    }\n  }\n\n  private static String attemptReadContent(okhttp3.Response response) {\n    try {\n      return readContent(response.body()).orElse(null);\n    } catch (IOException e) {\n      return null;\n    }\n  }\n\n  private static Optional<String> readContent(@Nullable ResponseBody body) throws IOException {\n    if (body == null) {\n      return empty();\n    }\n    try {\n      return of(body.string());\n    } finally {","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-alm-client/src/main/java/org/sonar/alm/client/GenericApplicationHttpClient.java#L202-L238","documentation":"GenericApplicationHttpClient.toAbsoluteEndPoint builds an absolute URL from the ALM host plus a relative endpoint, and throws IllegalArgumentException when the concatenated host+endpoint cannot be parsed as a valid URI/URL. The failing value is reported in the message so the misconfigured input can be identified. It guards any devops-platform integration (Azure DevOps, GitHub, etc.) backed by this generic client.","triggerScenarios":"Calling url()/toAbsoluteEndPoint where host or endPoint is malformed: missing scheme on host (e.g. 'myserver' instead of 'https://myserver'), illegal characters (spaces, unencoded '#', '?', '|'), an empty or null host with a relative endpoint, or an endPoint that does not start with 'http' while host+endPoint still fails URI parsing.","commonSituations":"Users enter 'sonarqube.company.com' or 'http://server with space' in the devops platform settings form instead of a fully qualified URL; copy-pasted URLs containing trailing spaces or unencoded special characters; empty host field left after an upgrade.","solutions":["Fix the ALM platform URL in SonarQube project administration settings to include scheme and no illegal characters (e.g. https://server.example.com).","URL-encode or remove special characters (spaces, #, %) from host and endpoint values.","Verify the host setting is non-empty in sonar.properties / alm settings before saving.","Escape the failing value from the message with new URI(host + endPoint) locally to pinpoint the illegal character."],"exampleFix":"// before (settings UI)\nalmsettingazure=devops.company.com\n\n// after\nalmsettingazure=https://devops.company.com","handlingStrategy":"validation","validationCode":"static boolean isValidAlmUrl(String host, String endpoint) {\n  String candidate = endpoint != null && endpoint.startsWith(\"http\") ? endpoint : host + endpoint;\n  try {\n    new URI(candidate).toURL();\n    return true;\n  } catch (URISyntaxException | IllegalArgumentException | MalformedURLException e) {\n    return false;\n  }\n}","typeGuard":"static boolean isValidUrl(String s) {\n  if (s == null || s.isBlank()) return false;\n  try { new java.net.URI(s).toURL(); return true; } catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n  String absolute = client.url(endpoint);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Configured ALM URL is invalid: {}\", e.getMessage());\n  throw new ConfigurationException(\"Fix the devops platform URL in settings\", e);\n}","preventionTips":["Always store ALM URLs with explicit https:// scheme in settings.","Reject URLs with spaces or unencoded special characters at input time (URL validation on the settings form).","Ping/validate the URL when saving the integration configuration.","Keep host and endpoint concatenation consistent; never leave the host setting empty."],"tags":["java","url","configuration"],"backgroundTag":"invalid-url-format","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"}