apache/iceberg · error · UnsupportedOperationException

Returning response headers is not supported

Error message

Returning response headers is not supported

What it means

The RESTClient default get(..., responseHeaders) overload cannot return response headers; passing a non-null Consumer<Map<String,String>> throws UnsupportedOperationException. Response-header capture requires a concrete client that supports it.

Solutions

  1. Use the get overload without the responseHeaders consumer if headers are not needed
  2. Use a concrete client implementation that supports response headers
  3. Capture needed information from the response body instead of headers when possible

Example fix

// before
client.get(path, params, type, headers, handler, hdrs -> save(hdrs));
// after
client.get(path, params, type, headers, handler); // or use a header-capable client
Defensive patterns

Strategy: validation

Validate before calling

if (responseHeaders != null) {
  throw new IllegalArgumentException("Default RESTClient.get cannot return response headers");
}

Try / catch

try {
  return client.get(path, params, type, headers, handler, responseHeaders);
} catch (UnsupportedOperationException e) {
  return client.get(path, params, type, headers, handler);
}

Prevention

When it happens

Trigger: Calling get(path, queryParams, responseType, headers, errorHandler, responseHeaders) with a non-null responseHeaders consumer on the default RESTClient interface; attempting to read headers like x-iceberg-access-delegation via the default overload.

Common situations: Code needing header metadata (e.g. access delegation hints) written against the interface default; mixing overloads when refactoring calls.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/088c4d47ad2298af. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/apache/iceberg/rest/RESTClient.java:131

  default <T extends RESTResponse> T get(
      String path,
      Map<String, String> queryParams,
      Class<T> responseType,
      Supplier<Map<String, String>> headers,
      Consumer<ErrorResponse> errorHandler,
      Consumer<Map<String, String>> responseHeaders) {
    return get(path, queryParams, responseType, headers.get(), errorHandler, responseHeaders);
  }

  default <T extends RESTResponse> T get(
      String path,
      Map<String, String> queryParams,
      Class<T> responseType,
      Map<String, String> headers,
      Consumer<ErrorResponse> errorHandler,
      Consumer<Map<String, String>> responseHeaders) {
    if (null != responseHeaders) {
      throw new UnsupportedOperationException("Returning response headers is not supported");
    }

    return get(path, queryParams, responseType, headers, errorHandler);
  }

  <T extends RESTResponse> T get(
      String path,
      Map<String, String> queryParams,
      Class<T> responseType,
      Map<String, String> headers,
      Consumer<ErrorResponse> errorHandler);

  default <T extends RESTResponse> T post(
      String path,
      RESTRequest body,
      Class<T> responseType,
      Supplier<Map<String, String>> headers,
      Consumer<ErrorResponse> errorHandler) {

View on GitHub (pinned to 86d9c8fc54)