pb33f / openapi-changes

The world's sexiest OpenAPI breaking changes detector. Discover what changed between two OpenAPI specs, or a single spec over time. Supports OpenAPI 3.1, 3.0 and Swagger
https://pb33f.io/openapi-changes/
Other
171 stars 16 forks source link

openapi change can crash in console rendering #139

Open LasneF opened 3 months ago

LasneF commented 3 months ago

given an API diff change got this errpr

openapi-changes version: 0.0.62 | compiled: Thu, 25 Apr 2024 16:39:09 UTC

DONE starting console...

panic: runtime error: slice bounds out of range [:2122] with capacity 2121 [recovered] panic: runtime error: slice bounds out of range [:2122] with capacity 2121

goroutine 1 [running]: github.com/rivo/tview.(Application).Run.func1() /home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20240424133105-0d02bb78244d/application.go:285 +0x45 panic({0x1820c40?, 0xc000c9bdb8?}) /opt/hostedtoolcache/go/1.22.2/x64/src/runtime/panic.go:770 +0x132 github.com/pb33f/openapi-changes/tui.RenderDiff(0xc000dec160?, 0xc000dec2c0, 0xc001806690, 0xc0001263f0) /home/runner/work/openapi-changes/openapi-changes/tui/diff_view.go:239 +0x4fbd github.com/pb33f/openapi-changes/tui.BuildApplication.func2(0x0?) /home/runner/work/openapi-changes/openapi-changes/tui/main_console.go:84 +0x3d github.com/rivo/tview.(TreeView).InputHandler.func1.1() /home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20240424133105-0d02bb78244d/treeview.go:769 +0x2f github.com/rivo/tview.(TreeView).InputHandler.func1(0xc000dec420?, 0xc00048c000?) /home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20240424133105-0d02bb78244d/treeview.go:822 +0xa2 github.com/rivo/tview.(TreeView).InputHandler.(Box).WrapInputHandler.func2(0xc00049d5e0?, 0xc000446008?) /home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20240424133105-0d02bb78244d/box.go:167 +0x50 github.com/rivo/tview.(Grid).InputHandler.func1(0xc001b777c0, 0xc001c7dc80) /home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20240424133105-0d02bb78244d/grid.go:663 +0x1b7 github.com/rivo/tview.(Grid).InputHandler.(Box).WrapInputHandler.func2(0xc000a95950?, 0xc000eaf768?) /home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20240424133105-0d02bb78244d/box.go:167 +0x50 github.com/rivo/tview.(Application).Run(0xc0015208c0) /home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20240424133105-0d02bb78244d/application.go:404 +0x9a2 github.com/pb33f/openapi-changes/cmd.runLeftRightCompare({0xc000022200, 0x3a}, {0xc00001e190, 0x50}, 0xc0000241e0, 0xc000024240, {0x0, 0x0}, 0x1)
/home/runner/work/openapi-changes/openapi-changes/cmd/console.go:383 +0x815 github.com/pb33f/openapi-changes/cmd.init.0.GetConsoleCommand.func1(0xc000158308, {0xc000088f40, 0x2, 0x18c80eb?}) /home/runner/work/openapi-changes/openapi-changes/cmd/console.go:248 +0x9af github.com/spf13/cobra.(
Command).execute(0xc000158308, {0xc000088ee0, 0x2, 0x2}) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca github.com/spf13/cobra.(Command).ExecuteC(0x234e3a0) /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({0x1ccf124?, 0x19?}, {0x1cd9660?, 0x18d87c5?}, {0xc000026be0?, 0xc00007a000?}) /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

    Looks on header added
LasneF commented 3 months ago

got a systematic way to reproduce

it occurs when the issue is like that image

and in term of report in this case { "breaking": true, "change": 2, "changeText": "property_added", "context": { "newLine": 2012, "newColumn": 18 }, "new": "bytes=[0-9]+-[0-9]+", "original": "", "property": "pattern" }