ExecuteWorkflow FORWARD compatibility

I’ve defined a workflow with a single input parameter. If I add a new parameter to the input struct without updating the workflow registration (so only the client is updated, not the workflow), so that the call to ExecuteWorkflow(ctx, opt, wf, STRUCT_WITH_NEW_FIELDS) I get the following error:

wrapError: unable to decode the workflow function input payload with error: payload item 0: unable to decode: unknown field "product" in models.OrderLineItem, function name: ReturnProcessWorkflow

It’s like there is no FORWARD compatibility because of the converter in Temporal being too strict. Is there any solution apart from switching the parameter type to string and manage myself the conversion??

Thanks a lot in advance

1 Like

Is models.OrderLineItem a protobuf? I am assuming so (if not, ignore the detail below).

By default we use proto JSON which by default disallows unknown fields. We use both the older jsonpb (a faster alternative to the common jsonpb) and the newer protojson both of which default to disallowing unknown fields.

You can make a new DataConverter like the default one but instead of the default proto JSON payload converter that does the unknown-fields-disallowed unmarshalling, you can set AllowUnknownFields unmarshal options and DiscardUnknown unmarshal options.

Hrmm, maybe we can support this in the ProtoJSONPayloadConverterOptions so you don’t have to write this yourself.

Alternatively, you could just remove the proto JSON payload converter from the set of payload converters when constructing that data converter and then it’d use binary proto which by default supports unknown fields, but you lose the easy-to-read aspect of the UI and it won’t be compatible with already-running workflows, so it’s not recommended.

1 Like

That was it, thanks a lot, I wasn’t aware of DataConverters. Forward compatibility is pretty useful when the updates are partials :slight_smile: