Skip to content

Commit

Permalink
fix: handle nil headers
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Feb 19, 2024
1 parent 66699ed commit e01b04a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
3 changes: 3 additions & 0 deletions backend/controller/ingress/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func ResponseForVerb(sch *schema.Schema, verb *schema.Verb, response HTTPRespons

// Clone and canonicalise the headers.
headers := http.Header(maps.Clone(response.Headers))
if headers == nil {
headers = http.Header{}
}
for k, v := range response.Headers {
headers[http.CanonicalHeaderKey(k)] = v
}
Expand Down
3 changes: 0 additions & 3 deletions backend/schema/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"

"github.com/alecthomas/participle/v2"
"github.com/alecthomas/repr"
"golang.design/x/reflect"
"golang.org/x/exp/maps"

Expand Down Expand Up @@ -218,8 +217,6 @@ func ValidateModule(module *Module) error {
if n.Module == "" {
merr = append(merr, fmt.Errorf("%s: unqualified reference to invalid data structure %q", n.Pos, n))
}
repr.Println(n)
repr.Println(mdecl)
n.Module = mdecl.Module.Name
}
} else if n.Module == "" || n.Module == module.Name { // Don't report errors for external modules.
Expand Down
2 changes: 0 additions & 2 deletions go-runtime/compile/schema_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package compile

import (
"fmt"
"go/ast"
"go/types"
"strings"
Expand Down Expand Up @@ -47,7 +46,6 @@ func TestExtractModuleSchema(t *testing.T) {

func TestExtractModuleSchemaTwo(t *testing.T) {
_, actual, err := ExtractModuleSchema("testdata/two")
fmt.Println(actual)
assert.NoError(t, err)
actual = schema.Normalise(actual)
expected := `module two {
Expand Down
3 changes: 0 additions & 3 deletions go-runtime/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"reflect"
"strings"

"github.com/alecthomas/repr"

"github.com/TBD54566975/ftl/backend/schema/strcase"
)

Expand Down Expand Up @@ -121,7 +119,6 @@ func encodeStruct(v reflect.Value, w *bytes.Buffer) error {
(t.String() == "ftl.Unit" && fv.IsZero()) ||
(strings.HasPrefix(t.String(), "ftl.Option[") && fv.IsZero()) ||
(t == reflect.TypeOf((*any)(nil)).Elem() && fv.IsZero()) {
repr.Println(ft.Name, fv.Interface())
continue
}
if afterFirst {
Expand Down

0 comments on commit e01b04a

Please sign in to comment.