Skip to content

Commit 9687d08

Browse files
sumanth-manchalageruhkevinjqliu
authored
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 <dru@amazon.com> Co-authored-by: Kevin Liu <kevinjqliu@users.noreply.github.com>
1 parent 48d074c commit 9687d08

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

pyiceberg/catalog/rest/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ class HttpMethod(str, Enum):
8888
HEAD = "HEAD"
8989
POST = "POST"
9090
DELETE = "DELETE"
91+
PUT = "PUT"
92+
CONNECT = "CONNECT"
93+
OPTIONS = "OPTIONS"
94+
TRACE = "TRACE"
95+
PATCH = "PATCH"
9196

9297

9398
class Endpoint(IcebergBaseModel):

tests/catalog/test_rest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
OAUTH2_SERVER_URI,
3636
SNAPSHOT_LOADING_MODE,
3737
Capability,
38+
Endpoint,
39+
HttpMethod,
3840
RestCatalog,
3941
)
4042
from pyiceberg.exceptions import (
@@ -2351,3 +2353,27 @@ def test_table_uuid_check_on_refresh(rest_mock: Mocker, example_table_metadata_v
23512353
assert "Table UUID does not match" in str(exc_info.value)
23522354
assert f"current={original_uuid}" in str(exc_info.value)
23532355
assert f"refreshed={different_uuid}" in str(exc_info.value)
2356+
2357+
2358+
def test_endpoint_parsing_from_string_with_valid_http_method() -> None:
2359+
test_cases = [
2360+
("GET /v1/resource", HttpMethod.GET, "/v1/resource"),
2361+
("HEAD /v1/resource", HttpMethod.HEAD, "/v1/resource"),
2362+
("POST /v1/resource", HttpMethod.POST, "/v1/resource"),
2363+
("DELETE /v1/resource", HttpMethod.DELETE, "/v1/resource"),
2364+
("PUT /v1/resource", HttpMethod.PUT, "/v1/resource"),
2365+
("CONNECT /v1/resource", HttpMethod.CONNECT, "/v1/resource"),
2366+
("OPTIONS /v1/resource", HttpMethod.OPTIONS, "/v1/resource"),
2367+
("TRACE /v1/resource", HttpMethod.TRACE, "/v1/resource"),
2368+
("PATCH /v1/resource", HttpMethod.PATCH, "/v1/resource"),
2369+
]
2370+
2371+
for raw_string, http_method, path in test_cases:
2372+
endpoint = Endpoint.from_string(raw_string)
2373+
assert endpoint.http_method == http_method
2374+
assert endpoint.path == path
2375+
2376+
2377+
def test_endpoint_parsing_from_string_with_invalid_http_method() -> None:
2378+
with pytest.raises(ValueError, match="not a valid HttpMethod"):
2379+
Endpoint.from_string("INVALID /v1/resource")

0 commit comments

Comments
 (0)