swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.63k stars 1.19k forks source link

nil pointer exception during execution #1752

Closed mathieu-chauvet closed 8 months ago

mathieu-chauvet commented 8 months ago

Describe the bug nil pointer exception during the execution and panic Stack trace :

github.com/swaggo/swag.(Operation).ParseParamComment(0x14000000b40, {0x140004488ca, 0x2c}, 0x2?) /Users/mathieuchauvet/go/pkg/mod/github.com/swaggo/swag@v1.16.3/operation.go:337 +0x1754 github.com/swaggo/swag.(Operation).ParseComment(0x14000000b40, {0x140004488c0?, 0x1?}, 0x140004a60c0?) /Users/mathieuchauvet/go/pkg/mod/github.com/swaggo/swag@v1.16.3/operation.go:145 +0x190 github.com/swaggo/swag.(Parser).ParseRouterAPIInfo(0x14000222400, 0x140004a8340) /Users/mathieuchauvet/go/pkg/mod/github.com/swaggo/swag@v1.16.3/parser.go:1006 +0x1a0 github.com/swaggo/swag.(PackagesDefinitions).RangeFiles(0x1400024b6b0, 0x14000597758) /Users/mathieuchauvet/go/pkg/mod/github.com/swaggo/swag@v1.16.3/packages.go:107 +0x27c github.com/swaggo/swag.(Parser).ParseAPIMultiSearchDir(0x14000222400, {0x1400024f460, 0x1, 0x0?}, {0x104a17a56, 0x7}, 0x64) /Users/mathieuchauvet/go/pkg/mod/github.com/swaggo/swag@v1.16.3/parser.go:454 +0x4a4 github.com/swaggo/swag/gen.(Gen).Build(0x1400024b4d0, 0x14000202420) /Users/mathieuchauvet/go/pkg/mod/github.com/swaggo/swag@v1.16.3/gen/gen.go:217 +0x6a0 main.initAction(0x14000238e00?) /Users/mathieuchauvet/go/pkg/mod/github.com/swaggo/swag@v1.16.3/cmd/swag/main.go:225 +0x8f4 github.com/urfave/cli/v2.(Command).Run(0x140001e0d80, 0x140001d3bc0) /Users/mathieuchauvet/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:163 +0x4a8 github.com/urfave/cli/v2.(App).RunContext(0x14000187860, {0x104be8398?, 0x104f64520}, {0x140001b6000, 0x2, 0x2}) /Users/mathieuchauvet/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:313 +0x808 github.com/urfave/cli/v2.(*App).Run(...) /Users/mathieuchauvet/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224 main.main() /Users/mathieuchauvet/go/pkg/mod/github.com/swaggo/swag@v1.16.3/cmd/swag/main.go:303 +0x540

To Reproduce Steps to reproduce the behavior: Sorry but I don't have an open repo to reproduce the error.

Expected behavior It should not end up with a panic

Screenshots If applicable, add screenshots to help explain your problem.

Your swag version 1.16.3

Your go version go1.21.5 darwin/arm64

Desktop (please complete the following information):

Additional context I think I have a fix ! Proposing a PR right after that!