Does any one have any tips for Unmarshaling respon...
# flyte-support
a
Does any one have any tips for Unmarshaling responses from flyte admin (in Go)? For example when I send a GET to
/api/v1/data/executions/{id}
with a execution id, the json response I get can't be Unmarshaled to the proper struct (located here). I'm especially having a hard time Unmarshaling `core.Literal`s
t
cc: @thankful-minister-83577 @glamorous-carpet-83516
h
@adamant-balloon-31283, can you share some of the code you're using? Also, can you paste a stacktrace of the error you're seeing?
a
@high-accountant-32689 thank you! I'm afk today, but I'll put that here tomorrow
👍 1
@high-accountant-32689 I am taking my GET response from
/api/v1/data/executions/{id}
(the raw json for that response is attached). Then I Unmarshal that into an
admin.WorkflowExecutionGetDataResponse
(which appears to be the correct output model according to the swagger docs) using the following code:
Copy code
data := admin.WorkflowExecutionGetDataResponse{}
err := json.Unmarshal(data_json, &data) // data_json is the raw response from flyte      

if err != nil {
        c.Data(status, "application/json", data_json) // return raw json
        return
}
c.JSON(status, data) // return unmarshalled object as json
It does successfully Unmarshal, but the resulting unmarshaled object
null
in all of the places the literals should be (see unmarshalled json attachment).
a
hey @adamant-balloon-31283 for json unmarshalling you'll want to use jsonpb, like we do here: https://github.com/flyteorg/flytestdlib/blob/4c2902e01eb526e9bac3bbfa29013c673ba6a7a8/utils/marshal_utils.go#L31
(it's frustrating because the json unmarshalling will happily not return an err even when it fails to populate the message 😞)
a
Appreciated! I'll give that a shot
155 Views