Skip to content

[Bug] RestCatalog initialization crashes with Apache Polaris due to unsupported HTTP methods (PUT) in ConfigResponse #3074

@maltzsama

Description

@maltzsama

Apache Iceberg version

None

Please describe the bug 🐞

Issue Description:

Describe the bug
When attempting to initialize a RestCatalog pointing to an Apache Polaris REST server, the initialization fails immediately. Apache Polaris returns valid REST endpoints that include the PUT HTTP method (e.g., for updating namespaces/tables). However, PyIceberg's Endpoint parser and Pydantic validation strictly expect only GET, HEAD, POST, or DELETE.

This causes two cascaded errors depending on the PyIceberg version:

  1. A TypeError: 'str' object is not callable when trying to instantiate the HttpMethod.
  2. A Pydantic ValidationError if the type casting is bypassed, explicitly stating that PUT is not an allowed enum value.

To Reproduce
Attempt to connect to an Apache Polaris catalog using RestCatalog:

from pyiceberg.catalog.rest import RestCatalog

catalog = RestCatalog(
    "iceberg",
    **{
        "uri": "http://<polaris-host>:8181/api/catalog",
        "credential": "<credential>",
        "warehouse": "iceberg",
    }
)

Expected behavior
The RestCatalog should initialize successfully, parse the valid PUT endpoints returned by the Polaris configuration, or at least gracefully ignore unsupported HTTP methods without crashing the entire initialization process.

Error Logs

Error 1: Type Error during Endpoint parsing

File /opt/conda/lib/python3.11/site-packages/pyiceberg/catalog/rest/__init__.py:116, in Endpoint.from_string(cls, endpoint)
    114 if len(elements) != 2:
    115     raise ValueError(f"Invalid endpoint: {endpoint}")
--> 116 return cls(http_method=HttpMethod(elements[0].upper()), path=elements[1])
TypeError: 'str' object is not callable

Error 2: Pydantic Validation Error (Underlying issue)

ValidationError: 1 validation error for ConfigResponse
endpoints.http_method
  Input should be 'GET', 'HEAD', 'POST' or 'DELETE' [type=enum, input_value='PUT', input_type=str]

Environment

  • PyIceberg version: 0.11.0
  • Apache Polaris version: 1.3.0-incubating
  • Python version: 3.11

Proposed Solution

  1. Update HttpMethod (Enum/Literal) in pyiceberg/catalog/rest/__init__.py to include PUT, PATCH, and OPTIONS.
  2. Ensure that unknown/future HTTP methods returned by a REST Catalog's /v1/config endpoint do not hard-crash the client.

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions