temporalio / temporalio/samples-go
Decoding fails when there is no cryptconverter.PropagateKey in the cryptconverter sample
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 749
- Forks
- 248
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 8
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cryptconverter/starter/main.go by reproducing the issue with the PropagateKey context line commented out. Then inspect cryptconverter/data-converter.go, especially the decoding path around the referenced line, to determine why the unpropagated payload becomes an array for a string input. Done means the workflow input decodes successfully without PropagateKey while the existing encrypted workflow path remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100