maltzsama opened a new issue, #3074:
URL: https://github.com/apache/iceberg-python/issues/3074

   ### 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`:
   
   ```python
   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*
   
   ```python
   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)*
   
   ```python
   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
   
   - [x] I can contribute a fix for this bug independently
   - [x] 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


-- 
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]

Reply via email to