Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarshalJSON for ClientWriteRequestWriteResponse and ClientWriteRequestDeleteResponse #144

Open
6 tasks done
dedo1911 opened this issue Nov 14, 2024 · 0 comments · May be fixed by openfga/sdk-generator#452 or #145
Open
6 tasks done
Labels
bug Something isn't working

Comments

@dedo1911
Copy link

dedo1911 commented Nov 14, 2024

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have upgraded to the latest version of OpenFGA and the issue still persists.
  • I have searched the Slack community and have not found a suitable solution or answer.
  • I agree to the terms within the OpenFGA Code of Conduct.

Description

Methods MarshalJSON for ClientWriteRequestWriteResponse and ClientWriteRequestDeleteResponse returns this error:

 *json.MarshalerError: json: error calling MarshalJSON for type *client.ClientWriteResponse:
    json: error calling MarshalJSON for type client.ClientWriteRequestWriteResponse:
        json: unsupported type: func() (io.ReadCloser, error)

HttpResponse should be omitted from json marshal to avoid this issue:

HttpResponse *_nethttp.Response `json:"http_response,omitempty"`

toSerialize["http_response"] = o.HttpResponse

toSerialize["http_response"] = o.HttpResponse

Expectation

I should be able to answer my clients with the result of a ClientWriteRequest

Reproduction

userId := 1
object := "document:1"
relation := "can_read"

res, _ := fga.Write(context.Background()).Body(client.ClientWriteRequest{
	Writes:  []openfga.TupleKey{{User: fmt.Sprintf("user:%s", userId), Object: object, Relation: relation}},
	Deletes: []openfga.TupleKeyWithoutCondition{},
}).Execute()
jsonResult, err := json.Marshal(res)
if err != nil {
  panic(err) // throws marshal error described above
}

OpenFGA SDK version

v0.6.3

OpenFGA version

v1.6.0

SDK Configuration

fga, err := client.NewSdkClient(&client.ClientConfiguration{ ApiUrl: "...", StoreId: "...", AuthorizationModelId: "..." })

Logs

No response

References

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
1 participant