This is an automated email from the ASF dual-hosted git repository.
kevinjqliu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git
The following commit(s) were added to refs/heads/main by this push:
new 9687d080f fix: Accept all valid http method for IRC's ConfigResponse
(#3010)
9687d080f is described below
commit 9687d080f28951464cf02fb2645e2a1185838b21
Author: Sumanth <[email protected]>
AuthorDate: Wed Feb 18 03:08:23 2026 +0530
fix: Accept all valid http method for IRC's ConfigResponse (#3010)
<!--
Thanks for opening a pull request!
-->
<!-- In the case this PR will resolve an issue, please replace
${GITHUB_ISSUE_ID} below with the actual Github issue id. -->
<!-- Closes #${GITHUB_ISSUE_ID} -->
# Rationale for this change
Apache Polaris on how it's configured returns some polaris's specific
PUT endpoints from the config/ API which would break the RestCatalog
with newly introduced validations on ConfigResponse
https://github.com/apache/polaris/blob/de43d1d84430547d3ff90df69afcce0bff7ede4c/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java#L1328-L1337
## Are these changes tested?
Yes, I have tested with my existing instance of Polaris service
## Are there any user-facing changes?
No
<!-- In the case of user-facing changes, please add the changelog label.
-->
cc: @geruh @kevinjqliu
---------
Co-authored-by: geruh <[email protected]>
Co-authored-by: Kevin Liu <[email protected]>
---
pyiceberg/catalog/rest/__init__.py | 5 +++++
tests/catalog/test_rest.py | 26 ++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/pyiceberg/catalog/rest/__init__.py
b/pyiceberg/catalog/rest/__init__.py
index 802be2856..69b1c17b9 100644
--- a/pyiceberg/catalog/rest/__init__.py
+++ b/pyiceberg/catalog/rest/__init__.py
@@ -88,6 +88,11 @@ class HttpMethod(str, Enum):
HEAD = "HEAD"
POST = "POST"
DELETE = "DELETE"
+ PUT = "PUT"
+ CONNECT = "CONNECT"
+ OPTIONS = "OPTIONS"
+ TRACE = "TRACE"
+ PATCH = "PATCH"
class Endpoint(IcebergBaseModel):
diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py
index 9fb1fa9af..4225d30d9 100644
--- a/tests/catalog/test_rest.py
+++ b/tests/catalog/test_rest.py
@@ -35,6 +35,8 @@ from pyiceberg.catalog.rest import (
OAUTH2_SERVER_URI,
SNAPSHOT_LOADING_MODE,
Capability,
+ Endpoint,
+ HttpMethod,
RestCatalog,
)
from pyiceberg.exceptions import (
@@ -2351,3 +2353,27 @@ def test_table_uuid_check_on_refresh(rest_mock: Mocker,
example_table_metadata_v
assert "Table UUID does not match" in str(exc_info.value)
assert f"current={original_uuid}" in str(exc_info.value)
assert f"refreshed={different_uuid}" in str(exc_info.value)
+
+
+def test_endpoint_parsing_from_string_with_valid_http_method() -> None:
+ test_cases = [
+ ("GET /v1/resource", HttpMethod.GET, "/v1/resource"),
+ ("HEAD /v1/resource", HttpMethod.HEAD, "/v1/resource"),
+ ("POST /v1/resource", HttpMethod.POST, "/v1/resource"),
+ ("DELETE /v1/resource", HttpMethod.DELETE, "/v1/resource"),
+ ("PUT /v1/resource", HttpMethod.PUT, "/v1/resource"),
+ ("CONNECT /v1/resource", HttpMethod.CONNECT, "/v1/resource"),
+ ("OPTIONS /v1/resource", HttpMethod.OPTIONS, "/v1/resource"),
+ ("TRACE /v1/resource", HttpMethod.TRACE, "/v1/resource"),
+ ("PATCH /v1/resource", HttpMethod.PATCH, "/v1/resource"),
+ ]
+
+ for raw_string, http_method, path in test_cases:
+ endpoint = Endpoint.from_string(raw_string)
+ assert endpoint.http_method == http_method
+ assert endpoint.path == path
+
+
+def test_endpoint_parsing_from_string_with_invalid_http_method() -> None:
+ with pytest.raises(ValueError, match="not a valid HttpMethod"):
+ Endpoint.from_string("INVALID /v1/resource")