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(
1243
1243
# To apply to typed search attributes we remove, replace, or add. We
1244
1244
# don't know any of the key types, so we do our best.
1245
1245
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
1247
1247
)
1248
1248
if not vals :
1249
1249
if index is not None :
@@ -1285,9 +1285,12 @@ def workflow_upsert_search_attributes(
1285
1285
1286
1286
# Update typed and untyped in info
1287
1287
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 ,
1291
1294
)
1292
1295
if update .value is None :
1293
1296
# Delete
@@ -1301,7 +1304,7 @@ def workflow_upsert_search_attributes(
1301
1304
update .key , update .value
1302
1305
)
1303
1306
if index is None :
1304
- mut_typed_attrs .append ()
1307
+ mut_typed_attrs .append (pair )
1305
1308
else :
1306
1309
mut_typed_attrs [index ] = pair
1307
1310
# 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(
1824
1824
assert updated_attrs_typed == await describe_attributes_typed (handle )
1825
1825
1826
1826
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
+
1827
1856
@workflow .defn
1828
1857
class LoggingWorkflow :
1829
1858
def __init__ (self ) -> None :
You can’t perform that action at this time.
0 commit comments