From 3eadae08e2b49d12c4b70a1919b96d9d216965f2 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Wed, 18 Feb 2026 08:30:05 -0600 Subject: [PATCH] Make search attribute type more lenient when parsing --- temporalio/common.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/temporalio/common.py b/temporalio/common.py index 70c70405b..d328863ed 100644 --- a/temporalio/common.py +++ b/temporalio/common.py @@ -378,19 +378,22 @@ def for_keyword_list(name: str) -> SearchAttributeKey[Sequence[str]]: @staticmethod def _from_metadata_type(name: str, metadata_type: str) -> SearchAttributeKey | None: - if metadata_type == "Text": + # The type metadata is usually in PascalCase (e.g. "KeywordList") + # but in rare cases may be in SCREAMING_SNAKE_CASE (e.g. + # "INDEXED_VALUE_TYPE_KEYWORD_LIST"). + if metadata_type in ("Text", "INDEXED_VALUE_TYPE_TEXT"): return SearchAttributeKey.for_text(name) - elif metadata_type == "Keyword": + elif metadata_type in ("Keyword", "INDEXED_VALUE_TYPE_KEYWORD"): return SearchAttributeKey.for_keyword(name) - elif metadata_type == "Int": + elif metadata_type in ("Int", "INDEXED_VALUE_TYPE_INT"): return SearchAttributeKey.for_int(name) - elif metadata_type == "Double": + elif metadata_type in ("Double", "INDEXED_VALUE_TYPE_DOUBLE"): return SearchAttributeKey.for_float(name) - elif metadata_type == "Bool": + elif metadata_type in ("Bool", "INDEXED_VALUE_TYPE_BOOL"): return SearchAttributeKey.for_bool(name) - elif metadata_type == "Datetime": + elif metadata_type in ("Datetime", "INDEXED_VALUE_TYPE_DATETIME"): return SearchAttributeKey.for_datetime(name) - elif metadata_type == "KeywordList": + elif metadata_type in ("KeywordList", "INDEXED_VALUE_TYPE_KEYWORD_LIST"): return SearchAttributeKey.for_keyword_list(name) return None