Requiring search attributes

I’m writing some code in a Workflow to prevent its execution if it does not have the required search attributes on it. This seems like it’d be a nice Temporal feature, but it also feels like maybe I’m using it wrong. I basically want to ensure everything is indexed on the account’s ID and reject workflows that are not.

I’ve also got some defensive code to attempt to upsert the search attribute if the Workflow can figure it out and only bail out in cases where it cannot be determined, however I think Workflow runs in this state would have a small gap where they aren’t indexed until the Workflow starts.

Is this a good way to proceed?

If you have to use search attributes you could use client interceptor and intercept client workflow start requests, and check if it has them defined in workflow options.
You can use same approach (client interceptor) to reject start requests based on workflow id too (in case you set workflow id to account id for example).
Which SDK are you using?

We’re using the Go SDK and the unofficial coinbase/temporal-ruby client. We’ll probably start workflows more often from the Ruby client.

1 Like