File tree Expand file tree Collapse file tree 2 files changed +37
-5
lines changed Expand file tree Collapse file tree 2 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -1243,7 +1243,7 @@ def workflow_upsert_search_attributes(
12431243 # To apply to typed search attributes we remove, replace, or add. We
12441244 # don't know any of the key types, so we do our best.
12451245 index = next (
1246- i for i , a in enumerate (mut_typed_attrs ) if a .key .name == k
1246+ ( i for i , a in enumerate (mut_typed_attrs ) if a .key .name == k ), None
12471247 )
12481248 if not vals :
12491249 if index is not None :
@@ -1285,9 +1285,12 @@ def workflow_upsert_search_attributes(
12851285
12861286 # Update typed and untyped in info
12871287 index = next (
1288- i
1289- for i , a in enumerate (mut_typed_attrs )
1290- if a .key .name == update .key .name
1288+ (
1289+ i
1290+ for i , a in enumerate (mut_typed_attrs )
1291+ if a .key .name == update .key .name
1292+ ),
1293+ None ,
12911294 )
12921295 if update .value is None :
12931296 # Delete
@@ -1301,7 +1304,7 @@ def workflow_upsert_search_attributes(
13011304 update .key , update .value
13021305 )
13031306 if index is None :
1304- mut_typed_attrs .append ()
1307+ mut_typed_attrs .append (pair )
13051308 else :
13061309 mut_typed_attrs [index ] = pair
13071310 # Single-item list if not already a sequence for untyped
Original file line number Diff line number Diff line change @@ -1824,6 +1824,35 @@ async def describe_attributes_typed(
18241824 assert updated_attrs_typed == await describe_attributes_typed (handle )
18251825
18261826
1827+ @workflow .defn
1828+ class NoSearchAttributesWorkflow :
1829+ @workflow .run
1830+ async def run (self ) -> None :
1831+ workflow .upsert_search_attributes (
1832+ [
1833+ SearchAttributeWorkflow .text_attribute .value_set ("text2" ),
1834+ ]
1835+ )
1836+ # All we need to do is complete
1837+
1838+
1839+ async def test_workflow_no_initial_search_attributes (client : Client , env_type : str ):
1840+ if env_type != "local" :
1841+ pytest .skip ("Only testing search attributes on local which disables cache" )
1842+ await ensure_search_attributes_present (
1843+ client ,
1844+ SearchAttributeWorkflow .text_attribute ,
1845+ )
1846+ async with new_worker (client , NoSearchAttributesWorkflow ) as worker :
1847+ handle = await client .start_workflow (
1848+ NoSearchAttributesWorkflow .run ,
1849+ id = f"workflow-{ uuid .uuid4 ()} " ,
1850+ task_queue = worker .task_queue ,
1851+ # importantly, no initial search attributes
1852+ )
1853+ await handle .result ()
1854+
1855+
18271856@workflow .defn
18281857class LoggingWorkflow :
18291858 def __init__ (self ) -> None :
You can’t perform that action at this time.
0 commit comments