waterWang opened a new pull request, #17766: URL: https://github.com/apache/iceberg/pull/17766
## Root cause `RESTUtil.encodeString()` uses `java.net.URLEncoder` which implements `application/x-www-form-urlencoded` encoding where a space becomes `+`. This is correct for OAuth form bodies (`encodeFormData`) but incorrect for URL path segments. When `ResourcePaths` places namespace levels, table names, view names, or scan plan IDs into REST resource URLs, the `+` is sent as a literal character — servers like Nessie that treat it as literal break, and names containing spaces become unreachable. ## Fix 1. **`RESTUtil.java`**: Added `encodePathSegment()` that uses proper percent-encoding (space → `%20`) for URL path segments. `encodeNamespace()` now uses `encodePathSegment()` for each namespace level since its javadoc states it is "suitable for use in a URL / URI". 2. **`ResourcePaths.java`**: All `RESTUtil.encodeString()` calls for table names, view names, and scan plan IDs in resource URL paths are switched to `RESTUtil.encodePathSegment()`. 3. **Tests**: Added `testEncodePathSegment` in `TestRESTUtil.java` verifying percent-encoding. Added namespace with spaces test case to the round-trip encoding test. Added `testTableWithSpace` in `TestResourcePaths.java`. Updated `cancelPlanEndpointPath` to expect `%20` instead of the incorrect `+` encoding. ## Compatibility `decodeString()` uses `URLDecoder.decode()` which handles both `+` and `%20` as spaces, so `decodeNamespace()` is fully backward-compatible with existing encoded data. Old clients that encoded spaces as `+` will still be decoded correctly. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
