From 6b4cd94c60d5d836e94c1b0ce6ed4f4c5922b454 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Fri, 20 Dec 2024 20:11:56 +0900 Subject: [PATCH 1/2] update goccy/go-yaml to v1.15.12 --- assert/assertion_test.go | 6 +++--- go.mod | 3 +-- go.sum | 14 ++------------ mock/protocol/grpc/handler_test.go | 4 ++-- schema/config_test.go | 8 ++++---- schema/load_test.go | 5 +++-- schema/testdata/broken.yaml | 2 +- schema/version.go | 4 ++++ schema/version_test.go | 4 ++-- template/template.go | 5 ++++- 10 files changed, 26 insertions(+), 29 deletions(-) diff --git a/assert/assertion_test.go b/assert/assertion_test.go index d8e119d9..ec83aeeb 100644 --- a/assert/assertion_test.go +++ b/assert/assertion_test.go @@ -278,9 +278,9 @@ deps: if err == nil { t.Error("no error") } else if got, expect := err.Error(), `failed to build assertion: .'{{call <-}}': failed to execute left arrow function: failed to unmarshal argument: [1:1] unknown field "func" - > 1 | func: "{{func-0}}" - ^ - 2 | arg: foo`; got != expect { +> 1 | func: "{{func-0}}" + ^ + 2 | arg: foo`; got != expect { t.Errorf("expect %q but got %q", expect, got) } }) diff --git a/go.mod b/go.mod index 8850d679..dde28984 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/bufbuild/protocompile v0.14.1 github.com/cenkalti/backoff/v4 v4.3.0 github.com/fatih/color v1.18.0 - github.com/goccy/go-yaml v1.12.0 + github.com/goccy/go-yaml v1.15.12 github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.6.0 github.com/hashicorp/go-multierror v1.1.1 @@ -41,5 +41,4 @@ require ( golang.org/x/crypto v0.26.0 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sys v0.25.0 // indirect - golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect ) diff --git a/go.sum b/go.sum index 60ff1075..8932212b 100644 --- a/go.sum +++ b/go.sum @@ -15,14 +15,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/goccy/go-yaml v1.12.0 h1:/1WHjnMsI1dlIBQutrvSMGZRQufVO3asrHfTwfACoPM= -github.com/goccy/go-yaml v1.12.0/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU= +github.com/goccy/go-yaml v1.15.12 h1:KLUSwfrUcTU6F8sAkf23OIPYC6aFVMNFSu4btROEm6w= +github.com/goccy/go-yaml v1.15.12/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= @@ -55,8 +49,6 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-encoding v0.0.2 h1:OC1L+QXLJge9n7yIE3R5Os/UNasUeFvK3Sa4NjbDi6c= @@ -130,8 +122,6 @@ golang.org/x/tools v0.1.1/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-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 h1:LLhsEBxRTBLuKlQxFBYUOU8xyFgXv6cOTp2HASDlsDk= -golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= diff --git a/mock/protocol/grpc/handler_test.go b/mock/protocol/grpc/handler_test.go index 0f36e492..781912c0 100644 --- a/mock/protocol/grpc/handler_test.go +++ b/mock/protocol/grpc/handler_test.go @@ -51,7 +51,7 @@ func TestUnaryHandler_failure(t *testing.T) { Expect: yamlutil.RawMessage("-"), }, }, - expect: "failed to unmarshal: [1:1] string was used where mapping is expected", + expect: "failed to unmarshal: [1:1] sequence was used where mapping is expected", }, "invalid expect service": { mocks: []protocol.Mock{ @@ -124,7 +124,7 @@ func TestUnaryHandler_failure(t *testing.T) { svcName: svcName, method: md, decode: func(_ any) error { return nil }, - expect: ".response: failed to unmarshal response: [1:1] string was used where mapping is expected", + expect: ".response: failed to unmarshal response: [1:1] sequence was used where mapping is expected", }, "failed to execute template of response": { mocks: []protocol.Mock{ diff --git a/schema/config_test.go b/schema/config_test.go index 8ad9fa50..754e5086 100644 --- a/schema/config_test.go +++ b/schema/config_test.go @@ -169,10 +169,10 @@ func TestLoadConfig(t *testing.T) { "invalid version": { path: "testdata/config/invalid-version.yaml", expect: `invalid version: [2:3] cannot unmarshal []interface {} into Go value of type string - 1 | schemaVersion: - > 2 | - config - ^ - 3 | - v1`, + 1 | schemaVersion: +> 2 | - config + ^ + 3 | - v1`, }, "invalid scenarios": { path: "testdata/config/invalid-scenarios.yaml", diff --git a/schema/load_test.go b/schema/load_test.go index a98889c4..51fccde2 100644 --- a/schema/load_test.go +++ b/schema/load_test.go @@ -363,8 +363,9 @@ func TestLoadScenarios(t *testing.T) { "invalid": { path: "testdata/invalid.yaml", expect: `failed to decode YAML: [1:8] cannot unmarshal yaml.MapSlice into Go struct field Scenario.Title of type string - > 1 | title: {} - ^`, +> 1 | title: {} + ^ +`, }, "unknown schema version": { path: "testdata/unknown-schema-version.yaml", diff --git a/schema/testdata/broken.yaml b/schema/testdata/broken.yaml index 39cdd0de..397db75f 100644 --- a/schema/testdata/broken.yaml +++ b/schema/testdata/broken.yaml @@ -1 +1 @@ -- +: diff --git a/schema/version.go b/schema/version.go index 3f11bb81..ae629af0 100644 --- a/schema/version.go +++ b/schema/version.go @@ -42,6 +42,10 @@ func readDocsWithSchemaVersionFromBytes(b []byte) ([]*docWithSchemaVersion, erro if len(f.Docs) == 0 { return nil, nil } + if len(f.Docs) == 1 && f.Docs[0].Body == nil { + // YAML interprets an empty string as null, so if docs body is nil, it should be treated as empty content. + return nil, nil + } docs := []*docWithSchemaVersion{} for _, doc := range f.Docs { diff --git a/schema/version_test.go b/schema/version_test.go index 283fc1d5..e6e2fce5 100644 --- a/schema/version_test.go +++ b/schema/version_test.go @@ -52,8 +52,8 @@ func TestReadDocWithSchemaVersions(t *testing.T) { }, "broken YAML": { path: "testdata/broken.yaml", - expect: `[1:1] empty sequence entry -> 1 | - + expect: `[1:1] unexpected key name +> 1 | : ^ `, }, diff --git a/template/template.go b/template/template.go index 41db1cda..0c5d9ad9 100644 --- a/template/template.go +++ b/template/template.go @@ -156,7 +156,10 @@ func (t *Template) executeParameterExpr(ctx context.Context, e *ast.ParameterExp } // Left arrow function arguments must be a string in YAML. - b, err := yaml.Marshal(v) + // If the `v` is a map or slice(array) instance, directly concatenating the output string would result in something like + // "a: key: value", which is invalid YAML. + // To resolve this problem, flow mode is used to create valid YAML, such as 'a: {key: value}'. + b, err := yaml.MarshalWithOptions(v, yaml.Flow(true)) if err != nil { return nil, err } From 92f3132fea1d6f9ae9be64ce6e6eaf80b1235116 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Fri, 20 Dec 2024 20:17:04 +0900 Subject: [PATCH 2/2] update CREDITS --- CREDITS | 141 -------------------------------------------------------- 1 file changed, 141 deletions(-) diff --git a/CREDITS b/CREDITS index bf172036..da3103a1 100644 --- a/CREDITS +++ b/CREDITS @@ -518,87 +518,6 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -================================================================ - -github.com/go-playground/locales -https://github.com/go-playground/locales ----------------------------------------------------------------- -The MIT License (MIT) - -Copyright (c) 2016 Go Playground - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -================================================================ - -github.com/go-playground/universal-translator -https://github.com/go-playground/universal-translator ----------------------------------------------------------------- -The MIT License (MIT) - -Copyright (c) 2016 Go Playground - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -================================================================ - -github.com/go-playground/validator/v10 -https://github.com/go-playground/validator/v10 ----------------------------------------------------------------- -The MIT License (MIT) - -Copyright (c) 2015 Dean Karn - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - ================================================================ github.com/goccy/go-yaml @@ -2731,33 +2650,6 @@ THE SOFTWARE. ================================================================ -github.com/leodido/go-urn -https://github.com/leodido/go-urn ----------------------------------------------------------------- -MIT License - -Copyright (c) 2018 Leonardo Di Donato - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -================================================================ - github.com/mattn/go-colorable https://github.com/mattn/go-colorable ---------------------------------------------------------------- @@ -3494,39 +3386,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================ -golang.org/x/xerrors -https://golang.org/x/xerrors ----------------------------------------------------------------- -Copyright 2019 The Go Authors. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google LLC nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -================================================================ - google.golang.org/genproto/googleapis/rpc https://google.golang.org/genproto/googleapis/rpc ----------------------------------------------------------------