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
package offerings import ( "context" "ftl/builtin" "github.com/TBD54566975/ftl/go-runtime/ftl" ) type GetOfferingsResponse struct { Data []string `json:"data"` } type ApiError struct { Error string `json:"error"` } //ftl:export //ftl:ingress GET /offerings func GetOfferings(ctx context.Context, req builtin.HttpRequest[builtin.Empty]) (builtin.HttpResponse[GetOfferingsResponse, ApiError], error) { r := GetOfferingsResponse{ Data: make([]string, 0), } return builtin.HttpResponse[GetOfferingsResponse, ApiError]{ Status: 200, Body: ftl.Some(r), }, nil }
❯ curl -v 'http://localhost:8892/ingress/offerings' * Trying [::1]:8892... * connect to ::1 port 8892 failed: Connection refused * Trying 127.0.0.1:8892... * Connected to localhost (127.0.0.1) port 8892 > GET /ingress/offerings HTTP/1.1 > Host: localhost:8892 > User-Agent: curl/8.4.0 > Accept: */* > < HTTP/1.1 200 OK < Content-Type: application/json; charset=utf-8 < Date: Mon, 08 Apr 2024 00:54:57 GMT < Content-Length: 2 < * Connection #0 to host localhost left intact {}
❯ curl -v 'http://localhost:8892/ingress/offerings' * Trying [::1]:8892... * connect to ::1 port 8892 failed: Connection refused * Trying 127.0.0.1:8892... * Connected to localhost (127.0.0.1) port 8892 > GET /ingress/offerings HTTP/1.1 > Host: localhost:8892 > User-Agent: curl/8.4.0 > Accept: */* > < HTTP/1.1 200 OK < Content-Type: application/json; charset=utf-8 < Date: Mon, 08 Apr 2024 00:54:57 GMT < Content-Length: 2 < * Connection #0 to host localhost left intact {"data": []}
switching the response body type to []byte at the cost of losing strong types e.g.
[]byte
package offerings import ( "context" "encoding/json" "ftl/builtin" "github.com/TBD54566975/ftl/go-runtime/ftl" ) type GetOfferingsResponse struct { Data []string `json:"data"` } type ApiError struct { Error string `json:"error"` } //ftl:export //ftl:ingress GET /offerings func GetOfferings(ctx context.Context, req builtin.HttpRequest[builtin.Empty]) (builtin.HttpResponse[[]byte, ApiError], error) { r := GetOfferingsResponse{ Data: make([]string, 0), } b, _ := json.Marshal(r) return builtin.HttpResponse[[]byte, ApiError]{ Status: 200, Body: ftl.Some(b), }, nil }
potentially has something to do with how marshaling ftl.Some handles zero values
ftl.Some
The text was updated successfully, but these errors were encountered:
The fields are omitted by the internal encoder here, but the bug is with the ingress marshaler in that it shouldn't be skipping them.
Sorry, something went wrong.
fix: ensure zero fields are included in ingress responses
51767d2
There should ideally be no relationship between the ingress encoder and the encoding package, but for now this is the simplest solution. Fixes #1196
fix: ensure zero fields are included in ingress responses (#1198)
bc2191c
alecthomas
Successfully merging a pull request may close this issue.
Repro
Expected Output
Workaround
switching the response body type to
[]byte
at the cost of losing strong types e.g.Other Thoughts
potentially has something to do with how marshaling
ftl.Some
handles zero valuesThe text was updated successfully, but these errors were encountered: