{"record":{"id":"2667044009ea790b","repo":"apache/iceberg","slug":"failed-to-create-request-uri-from-base-s-params","errorCode":null,"errorMessage":"Failed to create request URI from base %s, params %s","messagePattern":"Failed to create request URI from base (.+?), params (.+?)","errorType":"exception","errorClass":"RESTException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/rest/HTTPRequest.java","lineNumber":72,"sourceCode":"   * parameters. It cannot be modified directly.\n   */\n  @Value.Lazy\n  default URI requestUri() {\n    String fullPath;\n    if (hasAbsolutePath()) {\n      // if path is an absolute URI, use it as is\n      fullPath = path();\n    } else {\n      String baseUri = RESTUtil.stripTrailingSlash(baseUri().toString());\n      fullPath = RESTUtil.stripTrailingSlash(String.format(\"%s/%s\", baseUri, path()));\n    }\n\n    try {\n      URIBuilder builder = new URIBuilder(fullPath);\n      queryParameters().forEach(builder::addParameter);\n      return builder.build();\n    } catch (URISyntaxException e) {\n      throw new RESTException(\n          \"Failed to create request URI from base %s, params %s\", fullPath, queryParameters());\n    }\n  }\n\n  /** Returns the HTTP method of this request. */\n  HTTPMethod method();\n\n  /** Returns the path of this request. */\n  String path();\n\n  /** Returns the query parameters of this request. */\n  Map<String, String> queryParameters();\n\n  /** Returns the headers of this request. */\n  @Value.Default\n  default HTTPHeaders headers() {\n    return HTTPHeaders.EMPTY;\n  }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/rest/HTTPRequest.java#L54-L90","documentation":"HTTPRequest.requestUri builds the final request URI from the full path plus query parameters using URIBuilder. If URIBuilder.build() throws URISyntaxException (the path or parameter values are not valid URI components), the client throws RESTException with this message. It is raised by uri(), request(), and requestUriSuccess() whenever the request's path/query cannot be assembled.","triggerScenarios":"Building a request whose path() contains characters illegal in a URI (spaces, unencoded braces/brackets), or query parameters with values needing encoding passed through a path that already broke URI syntax; e.g. HTTPRequest.post(\"tables/ ns/table\") with queryParameters.","commonSituations":"Identifiers (namespace/table names) containing spaces or unicode interpolated into the path without URL-encoding; custom REST client code building paths with raw strings; config-supplied prefix paths containing invalid characters.","solutions":["URL-encode path segments with RESTUtil.encodeString (or URLEncoder) before interpolating identifiers into paths.","Pass query parameters via the request's queryParameters() map instead of concatenating '?a=b' into the path.","Strip or encode illegal characters from the base URI/path configuration.","Print fullPath and queryParameters() from the message to spot the offending segment."],"exampleFix":"// before\nString path = \"v1/namespaces/\" + namespace + \"/tables\"; // namespace has a space\n// after\nString path = \"v1/namespaces/\" + RESTUtil.encodeString(namespace) + \"/tables\";","handlingStrategy":"validation","validationCode":"String encoded = RESTUtil.encodeString(namespace);\nPreconditions.checkArgument(!fullPath.contains(\" \"), \"path contains a space: %s\", fullPath);","typeGuard":null,"tryCatchPattern":"try {\n  HTTPRequest req = HTTPRequest.get(path);\n} catch (RESTException e) {\n  if (e.getMessage().startsWith(\"Failed to create request URI\")) {\n    // encode path segments / move values into queryParameters()\n  }\n  throw e;\n}","preventionTips":["Always URL-encode identifiers interpolated into request paths.","Pass query parameters via queryParameters(), not string concatenation.","Avoid spaces and raw unicode in base URI and path configuration."],"tags":["url","rest-catalog","encoding"],"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"}