https://flyte.org logo
#ask-the-community
Title
# ask-the-community
g

George D. Torres

10/26/2022, 4:39 PM
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
s

Samhita Alla

10/27/2022, 4:20 AM
cc: @Yee @Kevin Su
e

Eduardo Apolinario (eapolinario)

10/27/2022, 5:04 PM
@George D. Torres, can you share some of the code you're using? Also, can you paste a stacktrace of the error you're seeing?
g

George D. Torres

10/27/2022, 5:09 PM
@Eduardo Apolinario (eapolinario) thank you! I'm afk today, but I'll put that here tomorrow
@Eduardo Apolinario (eapolinario) 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).
k

katrina

11/10/2022, 7:29 PM
hey @George D. Torres 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 😞)
g

George D. Torres

11/10/2022, 7:31 PM
Appreciated! I'll give that a shot