yumestk opened a new issue, #3775:
URL: https://github.com/apache/dubbo-go/issues/3775
### What happened?
protoc-gen-triple-openapi silently accepts invalid generator parameters.
For example, format=xml and unknown=1 should cause generation to fail
with a parameter error. Instead, generation succeeds and produces YAML.
The result also depends on parameter order:
- format=json,unknown=1 succeeds and produces JSON.
- unknown=1,format=json succeeds and produces YAML.
options.Generate returns an error, but convert does not check it.
The error is then overwritten by protodesc.NewFiles.
I have reproduced the problem locally and prepared a small fix with
regression tests. I would like to contribute the fix.
### How can we reproduce it? (optional)
On the original implementation at commit 94bc3a53, add the following
test to tools/protoc-gen-triple-openapi/internal/converter/convert_test.go.
It uses the existing greetRequest helper.
func TestConvertRejectsUnsupportedFormat(t *testing.T) {
_, err := convert(greetRequest("xml"))
if err == nil {
t.Fatal("expected an error for unsupported format")
}
}
From the tools/protoc-gen-triple-openapi module, run:
go test ./internal/converter -run '^TestConvertRejectsUnsupportedFormat$'
-count=1
The test fails because convert returns no error.
### Environment
dubbo-go: develop, commit 94bc3a53, before the local fix
Go: go1.27.1
OS: macOS arm64
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]