Contexts.payload: Discarded invalid value


I’m just getting started with the Go SDK, and trying to add a string with some additional context to my error event:

scope.SetContext("payload", hex.Dump(payload.Bytes())

I can see this context data is being sent to Sentry, here’s a snippet of the raw JSON event being received:

"_meta":{"contexts":{"payload":{"":{"val":"00000000  45 44 00 01 00                                    
|ED...|\n","err":[["invalid_data",{"reason":"expected an object"}]]}}}},"_metrics":{ "bytes.ingested.event":1685,"bytes.stored.event":3850},"contexts":{"device":{"num_cpu":4,"arch":"arm","type":"device"},"runtime":{"name":"go","go_numcgocalls":0,"go_numroutines":130,"version":"go1.14.2","go_maxprocs":4,"type":"runtime"},"os":{"type":"os","name":"linux"},"payload":null} ...

and the Sentry web UI shows:

There was 1 error encountered while processing this event

contexts.payload: Discarded invalid value
Reason expected an object
Value 00000000 45 44 00 01 00 |ED…|

What’s wrong with the way I’m sending this event? Do the values passed to SetContext need to be maps, or something else that the JSON encoder turns into an Object rather than just a string?

Thanks in advance for your input!

Switching to a map works:

scope.SetContext("payload", map[string]string{"client_handshake": hex.Dump(helloBuf.Bytes())})

I can’t find this requirement documented anywhere, but I guess this is OK.