temporalio / samples-go

Temporal Go SDK samples
https://docs.temporal.io/docs/go
Other
484 stars 197 forks source link

Decoding fails when there is no cryptconverter.PropagateKey in the cryptconverter sample #117

Open ghstahl opened 3 years ago

ghstahl commented 3 years ago

I want to be able to selectively decide if my workflow is to have its payloads encrypted. I am using the following sample project as a starter to prove I can do it.
samples-go/cryptconverter at master · temporalio/samples-go (github.com)

The following code is where I am focusing in on.

ctx := context.Background()
//ctx = context.WithValue(ctx, cryptconverter.PropagateKey, cryptconverter.CryptContext{KeyId: "test"})

// The workflow input "My Secret Friend" will be encrypted by the DataConverter before being sent to Temporal
we, err := c.ExecuteWorkflow(
  ctx,
  workflowOptions,
  cryptconverter.Workflow,
  "My Secret Friend",
  )

It should be easy as not putting in the the following;

ctx = context.WithValue(ctx, cryptconverter.PropagateKey, cryptconverter.CryptContext{KeyId: "test"})

The code in the sample does account for it not being there but I am running into a json.Unmarshal error when I remove it.

{
  "message": "unable to decode the workflow function input payload with error: args[0]: unable to decode: json: cannot unmarshal array into Go value of type string, function name: Workflow",
  "source": "GoSDK",
  "stackTrace": "",
  "cause": {
    "message": "args[0]: unable to decode: json: cannot unmarshal array into Go value of type string",
    "source": "GoSDK",
    "stackTrace": "",
    "cause": {
      "message": "unable to decode: json: cannot unmarshal array into Go value of type string",
      "source": "GoSDK",
      "stackTrace": "",
      "cause": {
        "message": "unable to decode",
        "source": "GoSDK",
        "stackTrace": "",
        "cause": null,
        "applicationFailureInfo": {
          "type": "",
          "nonRetryable": false,
          "details": null
        },
        "failureInfo": "applicationFailureInfo"
      },
      "applicationFailureInfo": {
        "type": "wrapError",
        "nonRetryable": false,
        "details": null
      },
      "failureInfo": "applicationFailureInfo"
    },
    "applicationFailureInfo": {
      "type": "wrapError",
      "nonRetryable": false,
      "details": null
    },
    "failureInfo": "applicationFailureInfo"
  },
  "applicationFailureInfo": {
    "type": "wrapError",
    "nonRetryable": false,
    "details": null
  },
  "failureInfo": "applicationFailureInfo"
}

In summary, I simply commented out the line that puts the cryptconverter.PropagateKey into the ExecuteWorkflow context.

robholland commented 2 years ago

Sorry for not seeing this sooner. I can't replicate this with the current version, can you confirm if this still occurs?