Closed ntotten closed 6 months ago
Hmm, this is odd, the second outcome is the desired one.
Is the only difference the working directory you're calling this from? i.e. packages/graphql/src/policies/graphql-complexity-limit-inbound/options.json
vs ./src/policies/graphql-complexity-limit-inbound/options.json
Also could you add the -w
flag, it will spit out debug messages.
Is there any chance I could get access to a trimmed down zip file so I can reproduce the issue locally?
Running it with the -w
flag. Oddly, it is not consistent. I ran it a few times and it worked once and failed two other times, but seemingly in slightly different ways (although i am no expert in go).
vacuum lint -k -s -d -e -b -w -r ./packages/runtime/config/policy-ruleset.yaml ./packages/graphql/src/policies/graphql-complexity-limit-inbound/options.json
INFO Linting file './packages/graphql/src/policies/graphql-complexity-limit-inbound/options.json' against 2 rules:
panic: runtime error: index out of range [1] with length 1
goroutine 112 [running]:
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x140015faf00, 0x14002647180, 0x14002646f00, {0x14004bbca40?, 0x1011ef9ee?, 0x2?}, 0xffffffffffffffff?, 0x20?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:185 +0x3464
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x140015faf00, 0x14002646f00, 0x14002646dc0, {0x14004bbca40?, 0x1014fab40?, 0x2?}, 0xffffffffffffffff?, 0x65?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:40 +0x238
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x140015faf00, 0x14002646dc0, 0x14001d75900, {0x14004329ea0?, 0x1011ef9ee?, 0x2?}, 0xffffffffffffffff?, 0xfa?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:40 +0x238
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x140015faf00, 0x14001d75900, 0x14001d5e280, {0x14004b8a210?, 0x1011ef9ee?, 0x2?}, 0xffffffffffffffff?, 0x0?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:40 +0x238
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x140015faf00, 0x14001d5e280, 0x14001d5e140, {0x14001f49db8?, 0x14953ec78?, 0x102769d28?}, 0x30?, 0x0?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:40 +0x238
github.com/pb33f/libopenapi/index.createNewIndex(0x14001d5e140, 0x140015faf00, 0x1)
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/spec_index.go:80 +0x158
github.com/pb33f/libopenapi/index.NewSpecIndexWithConfig(0x14001d5e140, 0x14000300480)
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/spec_index.go:51 +0x2d8
github.com/pb33f/libopenapi/index.(*LocalFile).Index(0x14001fb4500, 0xaebde78d89e5a894?)
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/rolodex_file_loader.go:191 +0x50
github.com/pb33f/libopenapi/index.(*Rolodex).IndexTheRolodex.func1.1({0x1494fe800, 0x14001fb4500}, {0x1400046b730, 0x66})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/rolodex.go:205 +0x124
created by github.com/pb33f/libopenapi/index.(*Rolodex).IndexTheRolodex.func1 in goroutine 25
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/rolodex.go:233 +0x27c
core on ξ main [$] via π³ desktop-linux via ξ v18.18.2 on βοΈ (us-east-2) on βοΈ nate@zuplo.com(us-central1)
β― vacuum lint -k -s -d -e -b -w -r packages/runtime/config/policy-ruleset.yaml packages/graphql/src/policies/graphql-complexity-limit-inbound/options.json
INFO Linting file 'packages/graphql/src/policies/graphql-complexity-limit-inbound/options.json' against 2 rules:
panic: runtime error: index out of range [5] with length 5
goroutine 1798 [running]:
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x14004323400, 0x14004cfa6e0, 0x14004cd8500, {0x14004b90550?, 0x10321f9ee?, 0x2?}, 0xffffffffffffffff?, 0x0?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:185 +0x3464
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x14004323400, 0x14004cd8500, 0x14004cd83c0, {0x14004905db8?, 0x12b53f6c8?, 0x1047993c8?}, 0x30?, 0x0?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:40 +0x238
github.com/pb33f/libopenapi/index.createNewIndex(0x14004cd83c0, 0x14004323400, 0x1)
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/spec_index.go:80 +0x158
github.com/pb33f/libopenapi/index.NewSpecIndexWithConfig(0x14004cd83c0, 0x14004368700)
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/spec_index.go:51 +0x2d8
github.com/pb33f/libopenapi/index.(*LocalFile).Index(0x1400030e0a0, 0xe6858ce58db8e48b?)
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/rolodex_file_loader.go:191 +0x50
github.com/pb33f/libopenapi/index.(*Rolodex).IndexTheRolodex.func1.1({0x12b4ba0f8, 0x1400030e0a0}, {0x1400220ca20, 0x51})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/rolodex.go:205 +0x124
created by github.com/pb33f/libopenapi/index.(*Rolodex).IndexTheRolodex.func1 in goroutine 20
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/rolodex.go:233 +0x27c
core on ξ main [$] via π³ desktop-linux via ξ v18.18.2 on βοΈ (us-east-2) on βοΈ nate@zuplo.com(us-central1)
β― vacuum lint -k -s -d -e -b -w -r packages/runtime/config/policy-ruleset.yaml packages/graphql/src/policies/graphql-complexity-limit-inbound/options.json
INFO Linting file 'packages/graphql/src/policies/graphql-complexity-limit-inbound/options.json' against 2 rules:
Linting passed, A perfect score! well done!
core on ξ main [$] via π³ desktop-linux via ξ v18.18.2 on βοΈ (us-east-2) on βοΈ nate@zuplo.com(us-central1)
β― vacuum lint -k -s -d -e -b -w -r packages/runtime/config/policy-ruleset.yaml packages/graphql/src/policies/graphql-complexity-limit-inbound/options.json
INFO Linting file 'packages/graphql/src/policies/graphql-complexity-limit-inbound/options.json' against 2 rules:
panic: runtime error: index out of range [1] with length 1
goroutine 191 [running]:
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x14003adc500, 0x14003a879a0, 0x14003a87860, {0x14003af82c0?, 0x1031cab40?, 0x2?}, 0xffffffffffffffff?, 0x0?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:185 +0x3464
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x14003adc500, 0x14003a87860, 0x14003a87720, {0x14003a81c00?, 0x1031cab40?, 0x2?}, 0xffffffffffffffff?, 0xe4?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:40 +0x238
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x14003adc500, 0x14003a87720, 0x14003a86640, {0x14003ae8830?, 0x102ebf9ee?, 0x2?}, 0xffffffffffffffff?, 0x0?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:40 +0x238
github.com/pb33f/libopenapi/index.(*SpecIndex).ExtractRefs(0x14003adc500, 0x14003a86640, 0x14003a86500, {0x14003675db8?, 0x1047d1460?, 0x104439d28?}, 0x30?, 0x80?, {0x0, 0x0})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/extract_refs.go:40 +0x238
github.com/pb33f/libopenapi/index.createNewIndex(0x14003a86500, 0x14003adc500, 0x1)
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/spec_index.go:80 +0x158
github.com/pb33f/libopenapi/index.NewSpecIndexWithConfig(0x14003a86500, 0x14003ad8080)
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/spec_index.go:51 +0x2d8
github.com/pb33f/libopenapi/index.(*LocalFile).Index(0x1400049d180, 0x20200a5d22656772?)
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/rolodex_file_loader.go:191 +0x50
github.com/pb33f/libopenapi/index.(*Rolodex).IndexTheRolodex.func1.1({0x12b2d5328, 0x1400049d180}, {0x140000451f0, 0x67})
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/rolodex.go:205 +0x124
created by github.com/pb33f/libopenapi/index.(*Rolodex).IndexTheRolodex.func1 in goroutine 19
/home/runner/go/pkg/mod/github.com/pb33f/libopenapi@v0.14.0/index/rolodex.go:233 +0x27c
Here is a minimal repro. It does seem to be the folder context is the key. One thing though in my repro I couldn't get it to actually panic - but it does log some errors. It might be that we have A LOT of various OpenAPI schemas in that repo, many of them are used for tests and many of them are invalid for the purposes of testing so if it is loading all the json/openapi files, its probably loading a lot of stuff.
This is very helpful, thank you! I am looking into this as a priority.
I have found the problem, it's a bug for sure, it's only triggered by the -k flag. Fixes are inbound.
Can you try v0.6.2
?
Fixed. THanks!
When i run this command using version 0.6.1:
I get the error:
The files in the error are in no way referenced or associated with the file I am trying to lint. The file I am linting is a random JSON schema file with no $refs, etc. Its not an OpenAPI file (thus the
-k
flag).If i change directories to
packages/graphql
and run the same command with the paths adjusted:The operations successfully lints the file.