We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If a project has an http ingress with a response spec that might return something like this
{ "data": [] }
Where the API specifies it will return an empty array, we currently strip the "data" field from the json response because of our encoding.
"data"
type GoodResponse struct { Data []string `json:"data"` } //ftl:export //ftl:ingress GET /good func Good(ctx context.Context, req builtin.HttpRequest[GoodRequest]) (builtin.HttpResponse[GoodResponse, builtin.Empty], error) { resp := GoodResponse{Data: []string{}} return builtin.HttpResponse[GoodResponse, builtin.Empty]{ Body: ftl.Some(resp), }, nil }
The code above will return {} where the user and API wants {"data":[]}.
{}
{"data":[]}
This seems to be happening here https://github.com/TBD54566975/ftl/blob/main/go-runtime/encoding/encoding.go#L119-L125.
Should we add some logic to honor omitempty for fields like this? Or remove the stripping of empty fields here? Or is there a better option for users?
omitempty
Currently, the work around is to use a response type of []byte and handle the json encoding manually in the user code.
[]byte
cc: @mistermoe
The text was updated successfully, but these errors were encountered:
alecthomas
No branches or pull requests
If a project has an http ingress with a response spec that might return something like this
{ "data": [] }
Where the API specifies it will return an empty array, we currently strip the
"data"
field from the json response because of our encoding.The code above will return
{}
where the user and API wants{"data":[]}
.This seems to be happening here https://github.com/TBD54566975/ftl/blob/main/go-runtime/encoding/encoding.go#L119-L125.
Should we add some logic to honor
omitempty
for fields like this? Or remove the stripping of empty fields here? Or is there a better option for users?Currently, the work around is to use a response type of
[]byte
and handle the json encoding manually in the user code.cc: @mistermoe
The text was updated successfully, but these errors were encountered: