Repository: goadesign/goa
Pull request #2872 (2021-06-14 06:02:27)

Bump golang.org/x/tools from 0.1.2 to 0.1.3
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.1.2 to 0.1.3.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/golang/tools/commit/13cf844527f48de3074270bb538dff67117a6655"><code>13cf844</code></a> go/ast/astutil: fix panic when rewriting multi-argument type instances</li>
<li><a href="https://github.com/golang/tools/commit/937957b6d95c21c64ecb70b1f94910330899afd3"><code>937957b</code></a> vta: adds VTA graph propagation functionality</li>
<li><a href="https://github.com/golang/tools/commit/e0b9cf74f60215fbb96eab9fc3c7e2ee2de2df71"><code>e0b9cf7</code></a> lsp/completion: support completing to Elem() types</li>
<li><a href="https://github.com/golang/tools/commit/16e5f55009722aea46b073567d4f7424ab3a38d8"><code>16e5f55</code></a> lsp/completion: search deeper for candidate type mods</li>
<li><a href="https://github.com/golang/tools/commit/b57987414902f9673c4051006d2d06a6c8c880e8"><code>b579874</code></a> lsp/completion: reorganize how we track candidate type mods</li>
<li><a href="https://github.com/golang/tools/commit/890984ba22125000b094316405734fa305065a2a"><code>890984b</code></a> internal/lsp: change generated variable names to be more verbose</li>
<li><a href="https://github.com/golang/tools/commit/9f230b5628613e4b8627cca0e69d4f5fd46db7d0"><code>9f230b5</code></a> internal/lsp: fix extract bug choosing available identifiers</li>
<li><a href="https://github.com/golang/tools/commit/4e58f8f09d6d4762e6f22c0ca9ba3eba103c2ad9"><code>4e58f8f</code></a> internal/lsp: handle out of range panic in template parsing</li>
<li><a href="https://github.com/golang/tools/commit/716319fe59d9638dd41a4a7ef3f3edadaaf03d01"><code>716319f</code></a> vta: finalizes VTA graph construction by adding support for function calls</li>
<li><a href="https://github.com/golang/tools/commit/234f954de338f5fc1d6baa2f967895a591e8dc85"><code>234f954</code></a> vta: extends VTA graph construction to handle collections</li>
<li>Additional commits viewable in <a href="https://github.com/golang/tools/compare/v0.1.2...v0.1.3">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/tools&package-manager=go_modules&previous-version=0.1.2&new-version=0.1.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/expr/root.go b/expr/root.go
index 92cea3ab..32e739ce 100644
--- a/expr/root.go
+++ b/expr/root.go
@@ -234,6 +234,9 @@ func (r *RootExpr) Finalize() {
 	if len(r.API.Servers) == 0 {
 		r.API.Servers = []*ServerExpr{r.API.DefaultServer()}
 	}
+	for _, e := range r.Errors {
+		e.Finalize()
+	}
 	for _, s := range r.API.Servers {
 		s.Finalize()
 	}
diff --git a/go.mod b/go.mod
index d57b6326..f0ecc8bf 100644
--- a/go.mod
+++ b/go.mod
@@ -18,7 +18,7 @@ require (
 	github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea
 	golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
 	golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
-	golang.org/x/tools v0.1.2
+	golang.org/x/tools v0.1.3
 	google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect
 	google.golang.org/grpc v1.38.0
 	google.golang.org/protobuf v1.26.0
diff --git a/go.sum b/go.sum
index cd052d31..2b288810 100644
--- a/go.sum
+++ b/go.sum
@@ -373,8 +373,8 @@ golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgw
 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
-golang.org/x/tools v0.1.2 h1:kRBLX7v7Af8W7Gdbbc908OJcdgtK8bOz9Uaj8/F1ACA=
-golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/tools v0.1.3 h1:L69ShwSZEyCsLKoAxDKeMvLDZkumEe8gXUZAjab0tX8=
+golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=


Test patch:
diff --git a/http/codegen/server_error_encoder_test.go b/http/codegen/server_error_encoder_test.go
index 445d2ee0..837f848c 100644
--- a/http/codegen/server_error_encoder_test.go
+++ b/http/codegen/server_error_encoder_test.go
@@ -15,7 +15,8 @@ func TestEncodeError(t *testing.T) {
 		Code string
 	}{
 		{"primitive-error-response", testdata.PrimitiveErrorResponseDSL, testdata.PrimitiveErrorResponseEncoderCode},
-		{"primitive-error-response", testdata.PrimitiveErrorInResponseHeaderDSL, testdata.PrimitiveErrorInResponseHeaderEncoderCode},
+		{"primitive-error-in-response-header", testdata.PrimitiveErrorInResponseHeaderDSL, testdata.PrimitiveErrorInResponseHeaderEncoderCode},
+		{"api-primitive-error-response", testdata.APIPrimitiveErrorResponseDSL, testdata.APIPrimitiveErrorResponseEncoderCode},
 		{"default-error-response", testdata.DefaultErrorResponseDSL, testdata.DefaultErrorResponseEncoderCode},
 		{"default-error-response-with-content-type", testdata.DefaultErrorResponseWithContentTypeDSL, testdata.DefaultErrorResponseWithContentTypeEncoderCode},
 		{"service-error-response", testdata.ServiceErrorResponseDSL, testdata.ServiceErrorResponseEncoderCode},
diff --git a/http/codegen/testdata/error_encoder_code.go b/http/codegen/testdata/error_encoder_code.go
index 7c675d41..22901630 100644
--- a/http/codegen/testdata/error_encoder_code.go
+++ b/http/codegen/testdata/error_encoder_code.go
@@ -80,6 +80,48 @@ func EncodeMethodPrimitiveErrorInResponseHeaderError(encoder func(context.Contex
 }
 `
 
+var APIPrimitiveErrorResponseEncoderCode = `// EncodeMethodAPIPrimitiveErrorResponseError returns an encoder for errors
+// returned by the MethodAPIPrimitiveErrorResponse
+// ServiceAPIPrimitiveErrorResponse endpoint.
+func EncodeMethodAPIPrimitiveErrorResponseError(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder, formatter func(err error) goahttp.Statuser) func(context.Context, http.ResponseWriter, error) error {
+	encodeError := goahttp.ErrorEncoder(encoder, formatter)
+	return func(ctx context.Context, w http.ResponseWriter, v error) error {
+		en, ok := v.(ErrorNamer)
+		if !ok {
+			return encodeError(ctx, w, v)
+		}
+		switch en.ErrorName() {
+		case "internal_error":
+			res := v.(*goa.ServiceError)
+			enc := encoder(ctx, w)
+			var body interface{}
+			if formatter != nil {
+				body = formatter(res)
+			} else {
+				body = NewMethodAPIPrimitiveErrorResponseInternalErrorResponseBody(res)
+			}
+			w.Header().Set("goa-error", res.ErrorName())
+			w.WriteHeader(http.StatusInternalServerError)
+			return enc.Encode(body)
+		case "bad_request":
+			res := v.(serviceapiprimitiveerrorresponse.BadRequest)
+			enc := encoder(ctx, w)
+			var body interface{}
+			if formatter != nil {
+				body = formatter(res)
+			} else {
+				body = NewMethodAPIPrimitiveErrorResponseBadRequestResponseBody(res)
+			}
+			w.Header().Set("goa-error", res.ErrorName())
+			w.WriteHeader(http.StatusBadRequest)
+			return enc.Encode(body)
+		default:
+			return encodeError(ctx, w, v)
+		}
+	}
+}
+`
+
 var DefaultErrorResponseEncoderCode = `// EncodeMethodDefaultErrorResponseError returns an encoder for errors returned
 // by the MethodDefaultErrorResponse ServiceDefaultErrorResponse endpoint.
 func EncodeMethodDefaultErrorResponseError(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder, formatter func(err error) goahttp.Statuser) func(context.Context, http.ResponseWriter, error) error {
diff --git a/http/codegen/testdata/error_response_dsls.go b/http/codegen/testdata/error_response_dsls.go
index ae4d214e..3ca89af4 100644
--- a/http/codegen/testdata/error_response_dsls.go
+++ b/http/codegen/testdata/error_response_dsls.go
@@ -62,6 +62,25 @@ var PrimitiveErrorInResponseHeaderDSL = func() {
 	})
 }
 
+var APIPrimitiveErrorResponseDSL = func() {
+	var _ = API("test", func() {
+		Error("bad_request", String)
+		HTTP(func() {
+			Response(StatusBadRequest, "bad_request")
+		})
+	})
+	Service("ServiceAPIPrimitiveErrorResponse", func() {
+		Method("MethodAPIPrimitiveErrorResponse", func() {
+			Error("bad_request", String)
+			Error("internal_error")
+			HTTP(func() {
+				GET("/one/two")
+				Response("internal_error", StatusInternalServerError)
+			})
+		})
+	})
+}
+
 var ServiceErrorResponseDSL = func() {
 	Service("ServiceServiceErrorResponse", func() {
 		Error("bad_request")