From 4f45ca554e4f483e5abf045b14a47ca4005ee5e3 Mon Sep 17 00:00:00 2001 From: Anas Khan <83116240+anxkhn@users.noreply.github.com> Date: Mon, 27 Jul 2026 19:07:55 +0530 Subject: [PATCH] fix: decode DynamoDB namespace property keys with removeprefix Use str.removeprefix directly when decoding namespace properties so the literal p. prefix is removed without stripping leading property-key characters. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com> --- pyiceberg/catalog/dynamodb.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pyiceberg/catalog/dynamodb.py b/pyiceberg/catalog/dynamodb.py index 74c0be6c9a..10f74fb9a0 100644 --- a/pyiceberg/catalog/dynamodb.py +++ b/pyiceberg/catalog/dynamodb.py @@ -837,7 +837,10 @@ def _get_update_database_item(namespace_item: dict[str, Any], updated_properties def _get_namespace_properties(namespace_dict: dict[str, str]) -> Properties: - return {_remove_property_prefix(key): val for key, val in namespace_dict.items() if key.startswith(PROPERTY_KEY_PREFIX)} + # removeprefix removes the literal prefix, unlike lstrip which removes any leading prefix characters + return { + key.removeprefix(PROPERTY_KEY_PREFIX): val for key, val in namespace_dict.items() if key.startswith(PROPERTY_KEY_PREFIX) + } def _convert_dynamo_item_to_regular_dict(dynamo_json: dict[str, Any]) -> dict[str, str]: @@ -888,7 +891,3 @@ def _convert_dynamo_item_to_regular_dict(dynamo_json: dict[str, Any]) -> dict[st def _add_property_prefix(prop: str) -> str: return PROPERTY_KEY_PREFIX + prop - - -def _remove_property_prefix(prop: str) -> str: - return prop.lstrip(PROPERTY_KEY_PREFIX)