{"record":{"id":"bef895bfb3786ef4","repo":"apache/druid","slug":"uri-s-has-invalid-scheme-s","errorCode":null,"errorMessage":"URI[%s] has invalid scheme[%s]","messagePattern":"URI\\[(.+?)\\] has invalid scheme\\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/rpc/ServiceLocation.java","lineNumber":119,"sourceCode":"      }\n    }\n\n    if (uri.getRawQuery() != null) {\n      basePath.append('?').append(uri.getRawQuery());\n    }\n\n    if (uri.getRawFragment() != null) {\n      basePath.append('#').append(uri.getRawFragment());\n    }\n\n    if (HTTP_SCHEME.equals(scheme)) {\n      final int port = uri.getPort() < 0 ? HTTP_DEFAULT_PORT : uri.getPort();\n      return new ServiceLocation(host, port, -1, basePath.toString());\n    } else if (HTTPS_SCHEME.equals(scheme)) {\n      final int port = uri.getPort() < 0 ? HTTPS_DEFAULT_PORT : uri.getPort();\n      return new ServiceLocation(host, -1, port, basePath.toString());\n    } else {\n      throw new IAE(\"URI[%s] has invalid scheme[%s]\", uri, scheme);\n    }\n  }\n\n  /**\n   * Create a service location based on a {@link DruidServerMetadata}.\n   *\n   * @throws IllegalArgumentException if the server metadata cannot be mapped to a service location.\n   */\n  public static ServiceLocation fromDruidServerMetadata(final DruidServerMetadata druidServerMetadata)\n  {\n    final String host = getHostFromString(\n        Preconditions.checkNotNull(\n            druidServerMetadata.getHost(),\n            \"Host was null for druid server metadata[%s]\",\n            druidServerMetadata\n        )\n    );\n    int plaintextPort = getPortFromString(druidServerMetadata.getHostAndPort());","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/rpc/ServiceLocation.java#L101-L137","documentation":"ServiceLocation.fromUri converts a URI into a service location, but only http and https schemes are supported. Any other scheme (e.g. ws, ftp, or a missing scheme) causes this IllegalArgumentException. It exists to fail fast on URIs that cannot map to an HTTP service endpoint.","triggerScenarios":"Calling ServiceLocation.fromUri with a URI whose scheme is not exactly \"http\" or \"https\" — e.g. fromUri(new URI(\"ftp://host:8020\")) or a URI built from a config string lacking a scheme.","commonSituations":"Misconfigured service URLs in Druid properties (forgot http:// prefix), copy-pasted internal scheme names (https vs websockets), or programmatically constructed URIs with relative paths that resolve to a null scheme.","solutions":["Prefix the URI string with \"http://\" (or \"https://\") in the configuration or code that builds it.","Check the scheme before calling fromUri and normalize known aliases to http/https.","Verify the config property feeding the URI (e.g. druid.discovery URLs) is a full absolute URL."],"exampleFix":"// before\nServiceLocation loc = ServiceLocation.fromUri(new URI(\"mybroker:8082\"), basePath);\n// after\nServiceLocation loc = ServiceLocation.fromUri(new URI(\"http://mybroker:8082\"), basePath);","handlingStrategy":"validation","validationCode":"String s = uri.toString();\nif (!s.startsWith(\"http://\") && !s.startsWith(\"https://\")) {\n  throw new IllegalArgumentException(\"Service URI must use http/https: \" + s);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always store fully-qualified http(s) URLs in configuration, never bare host:port.","Normalize scheme aliases in one helper before constructing URIs."],"tags":["url-validation","illegal-argument","rpc"],"backgroundTag":"invalid-url-format","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}