Skip to content

Commit 3a5611a

Browse files
authored
fix: Default searchAttributes to {} and edit type (#738)
1 parent 5e7a065 commit 3a5611a

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

packages/internal-workflow-common/src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ export type WorkflowResultType<W extends Workflow> = ReturnType<W> extends Promi
4545
*
4646
* Dates are serialized as ISO strings.
4747
*/
48-
export type SearchAttributes = Record<string, SearchAttributeValue>;
48+
export type SearchAttributes = Record<string, SearchAttributeValue | undefined>;
4949
export type SearchAttributeValue = string[] | number[] | boolean[] | Date[];

packages/test/src/integration-tests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
678678
taskTimeoutMs: 10_000,
679679
runId: workflow.firstExecutionRunId,
680680
taskQueue: 'test',
681+
searchAttributes: {},
681682
workflowType: 'returnWorkflowInfo',
682683
workflowId,
683684
});

packages/test/src/test-sinks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ if (RUN_INTEGRATION_TESTS) {
9999
lastResult: undefined,
100100
memo: undefined,
101101
parent: undefined,
102-
searchAttributes: undefined,
102+
searchAttributes: {},
103103
};
104104

105105
t.deepEqual(recordedCalls, [

packages/test/src/test-workflows.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ async function createWorkflow(
9090
attempt: 1,
9191
taskTimeoutMs: 1000,
9292
taskQueue: 'test',
93+
searchAttributes: {},
9394
},
9495
randomnessSeed: Long.fromInt(1337).toBytes(),
9596
now: startTime,

packages/worker/src/worker.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,10 +1030,11 @@ export class Worker {
10301030
workflowId,
10311031
runId: activation.runId,
10321032
workflowType,
1033-
searchAttributes: mapFromPayloads(
1034-
searchAttributePayloadConverter,
1035-
searchAttributes?.indexedFields
1036-
) as SearchAttributes | undefined,
1033+
searchAttributes:
1034+
(mapFromPayloads(
1035+
searchAttributePayloadConverter,
1036+
searchAttributes?.indexedFields
1037+
) as SearchAttributes) || {},
10371038
memo: await decodeMapFromPayloads(this.options.loadedDataConverter, memo?.fields),
10381039
parent: convertToParentWorkflowType(parentWorkflowInfo),
10391040
lastResult: await decodeFromPayloadsAtIndex(

packages/workflow/src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface WorkflowInfo {
2525
/**
2626
* Indexed information attached to the Workflow Execution
2727
*/
28-
searchAttributes?: SearchAttributes;
28+
searchAttributes: SearchAttributes;
2929

3030
/**
3131
* Non-indexed information attached to the Workflow Execution

0 commit comments

Comments
 (0)