Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on Summary if Starting Document Has no Components #130

Open
DapperMongoose opened this issue Apr 25, 2024 · 1 comment
Open

Crash on Summary if Starting Document Has no Components #130

DapperMongoose opened this issue Apr 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@DapperMongoose
Copy link

DapperMongoose commented Apr 25, 2024

Hello again, still a big fan of these tools!

I've discovered that if the spec you start from lacks a components property and then you compare with a spec that has components added, running the summary command will cause a crash. Adding an empty components property to the starting spec fixes the problem.

Interestingly enough HTML report generation seems to work correctly without the empty property.

Here's a zip file with some minimal reproduction specs: examples.zip
(Note: adding an empty components property to the new file will also cause the crash but I've added a mock schema to be more correct to the real use case that produced the error)

And here is the command and result of running against the attached files:

openapi-changes summary start-spec.yaml compare-spec.yaml 

@@@@@@@   @@@@@@@   @@@@@@   @@@@@@   @@@@@@@@
@@@@@@@@  @@@@@@@@  @@@@@@@  @@@@@@@  @@@@@@@@
@@!  @@@  @@!  @@@      @@@      @@@  @@!
!@!  @!@  !@   @!@      @!@      @!@  !@!
@!@@!@!   @!@!@!@   @!@!!@   @!@!!@   @!!!:!
!!@!!!    !!!@!!!!  !!@!@!   !!@!@!   !!!!!:
!!:       !!:  !!!      !!:      !!:  !!:
:!:       :!:  !:!      :!:      :!:  :!:
 ::        :: ::::  :: ::::  :: ::::   ::
 :        :: : ::    : : :    : : :    :


🔗 https://pb33f.io/openapi-changes/
------------------------------------
openapi-changes version: 0.0.62 | compiled: Thu, 25 Apr 2024 16:39:09 UTC

▀  Building original model for commit ef697c
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb2c22a]

goroutine 1 [running]:
github.com/pb33f/openapi-changes/cmd.generateTreeState(0xc000404230, 0xe0?)
        /home/runner/work/openapi-changes/openapi-changes/cmd/tree.go:192 +0x32a
github.com/pb33f/openapi-changes/cmd.buildConsoleTreeNode(0xc000451440, {0xc066e0, 0xc000410100}, 0x0, 0x0)
        /home/runner/work/openapi-changes/openapi-changes/cmd/tree.go:36 +0x2afa
github.com/pb33f/openapi-changes/cmd.buildConsoleTree(0xc000451546?, 0x0)
        /home/runner/work/openapi-changes/openapi-changes/cmd/tree.go:205 +0x54
github.com/pb33f/openapi-changes/cmd.printSummaryDetails({0xc00040aff0, 0x2, 0xc000451a90?}, 0x0)
        /home/runner/work/openapi-changes/openapi-changes/cmd/summary.go:418 +0x40c
github.com/pb33f/openapi-changes/cmd.runLeftRightSummary({0x7ffd7e80916a, 0xf}, {0x7ffd7e80917a, 0x11}, 0xc00028c060, 0xc00028c0c0, {0x0, 0x0}, 0x1, 0x0)
        /home/runner/work/openapi-changes/openapi-changes/cmd/summary.go:345 +0x91a
github.com/pb33f/openapi-changes/cmd.GetSummaryCommand.func1(0xc000178608, {0xc00012c5e0, 0x2, 0xd38f0b?})
        /home/runner/work/openapi-changes/openapi-changes/cmd/summary.go:236 +0x717
github.com/spf13/cobra.(*Command).execute(0xc000178608, {0xc00012c580, 0x2, 0x2})
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0x17b2420)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/pb33f/openapi-changes/cmd.Execute({0x113f42c?, 0x19?}, {0x1149940?, 0xd4767a?}, {0xc00012a640?, 0xc0000061c0?})
        /home/runner/work/openapi-changes/openapi-changes/cmd/root.go:51 +0x91
main.main()
        /home/runner/work/openapi-changes/openapi-changes/openapi-changes.go:29 +0x158
@daveshanley
Copy link
Member

Oh dear, willfix.

@daveshanley daveshanley added the bug Something isn't working label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants