{"record":{"id":"b6386998a1229fd3","repo":"apache/iceberg","slug":"failed-to-create-request-uri-from-base-s","errorCode":null,"errorMessage":"Failed to create request URI from base %s","messagePattern":"Failed to create request URI from base (.+?)","errorType":"exception","errorClass":"RESTException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/rest/HTTPClient.java","lineNumber":519,"sourceCode":"  public static class Builder {\n    private final Map<String, String> properties;\n    private final Map<String, String> baseHeaders = Maps.newHashMap();\n    private URI uri;\n    private ObjectMapper mapper = RESTObjectMapper.mapper();\n    private HttpHost proxy;\n    private CredentialsProvider proxyCredentialsProvider;\n    private AuthSession authSession;\n\n    private Builder(Map<String, String> properties) {\n      this.properties = properties;\n    }\n\n    public Builder uri(String baseUri) {\n      Preconditions.checkNotNull(baseUri, \"Invalid uri for http client: null\");\n      try {\n        this.uri = URI.create(RESTUtil.stripTrailingSlash(baseUri));\n      } catch (IllegalArgumentException e) {\n        throw new RESTException(e, \"Failed to create request URI from base %s\", baseUri);\n      }\n      return this;\n    }\n\n    public Builder uri(URI baseUri) {\n      Preconditions.checkNotNull(baseUri, \"Invalid uri for http client: null\");\n      this.uri = baseUri;\n      return this;\n    }\n\n    public Builder withProxy(String hostname, int port) {\n      Preconditions.checkNotNull(hostname, \"Invalid hostname for http client proxy: null\");\n      this.proxy = new HttpHost(hostname, port);\n      return this;\n    }\n\n    public Builder withProxyCredentialsProvider(CredentialsProvider credentialsProvider) {\n      Preconditions.checkNotNull(","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/rest/HTTPClient.java#L501-L537","documentation":"The HTTPClient.Builder.uri(String) method parses the configured base URI after stripping a trailing slash. If URI.create rejects the string (IllegalArgumentException), it is rethrown as RESTException with this message. It means the catalog base URI string is not a syntactically valid URI.","triggerScenarios":"Calling HTTPClient.Builder.uri(String) (directly or via REST catalog catalog initialization) with a malformed base URI — e.g. containing spaces, unencoded special characters like unescaped '|', or a bad scheme.","commonSituations":"Catalog URI read from an environment variable or config file containing a trailing space or newline; unencoded characters in the URL; scheme typo like 'http:/catalog' (single slash); quotes accidentally included in the config value.","solutions":["Print and inspect the base URI string; trim whitespace and newlines around it.","Percent-encode special characters (e.g. spaces as %20) or remove them from the URI.","Validate the URI with java.net.URI.create in a quick test before configuring the client.","Fix the source of the value (env var, catalog config, properties file) that embeds invalid characters."],"exampleFix":"// before\nString baseUri = System.getenv(\"CATALOG_URI\"); // \"http://rest:8181 \"\nbuilder.uri(baseUri);\n// after\nbuilder.uri(System.getenv(\"CATALOG_URI\").trim());","handlingStrategy":"validation","validationCode":"String baseUri = config.get(\"uri\").trim();\nURI.create(RESTUtil.stripTrailingSlash(baseUri)); // throws early with a clear message\nbuilder.uri(baseUri);","typeGuard":null,"tryCatchPattern":"try {\n  builder.uri(baseUri);\n} catch (RESTException e) {\n  if (e.getMessage().startsWith(\"Failed to create request URI from base\")) {\n    // log baseUri repr and fix config source\n  }\n  throw e;\n}","preventionTips":["Trim whitespace/newlines from URIs read from env vars and config files.","Percent-encode special characters in URIs.","Validate the catalog URI at application startup, not lazily."],"tags":["url","configuration","rest-catalog"],"backgroundTag":"invalid-url-format","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}