daveshanley / vacuum

vacuum is the worlds fastest OpenAPI 3, OpenAPI 2 / Swagger linter and quality analysis tool. Built in go, it tears through API specs faster than you can think. vacuum is compatible with Spectral rulesets and generates compatible reports.
https://quobix.com/vacuum
MIT License
490 stars 39 forks source link

regression in handling of circular references #389

Closed TristanSpeakEasy closed 6 months ago

TristanSpeakEasy commented 7 months ago

The attached document has a regression in handling of circular references.

As an example it complains about infinite circular reference detected: results: stats -> results -> results [20266:7] | stats -> results -> results but this circular reference doesn't actually exists, results doesn't link to itself at all.

So it seems to be erroneously marking things as circular references that aren't

Here is the list of errors:

ERROR   validation error: [line 20266] resolving-references - infinite circular reference detected: results: stats -> results -> results [20266:7] | stats -> results -> results
ERROR   validation error: [line 20266] resolving-references - infinite circular reference detected: #/components/schemas/results: stats -> results -> results [20266:7] | stats -> results -> results
ERROR   validation error: [line 20266] resolving-references - infinite circular reference detected: results: stats -> results -> results [20266:7] | stats -> results -> results
ERROR   validation error: [line 22794] resolving-references - infinite circular reference detected: realtime_measurements: realtime -> realtime_entry -> realtime_measurements -> object_size_1g [22794:7] | realtime -> realtime_entry -> realtime_measurements -> object_size_1g
ERROR   validation error: [line 22794] resolving-references - infinite circular reference detected: #/components/schemas/realtime_measurements: realtime -> realtime_entry -> realtime_measurements -> object_size_1g [22794:7] | realtime -> realtime_entry -> realtime_measurements -> object_size_1g
ERROR   validation error: [line 22794] resolving-references - infinite circular reference detected: realtime_measurements: realtime -> realtime_entry -> realtime_measurements -> object_size_1g [22794:7] | realtime -> realtime_entry -> realtime_measurements -> object_size_1g

openapi.zip

These errors weren't showing in vacuum v0.4.3 the previous version we were using

daveshanley commented 7 months ago

does this show up in libopenapi also?

TristanSpeakEasy commented 7 months ago

does this show up in libopenapi also?

good question I don't know, our code bails out before this gets to the point we are interacting with the libopenapi model

daveshanley commented 7 months ago

https://github.com/pb33f/libopenapi/blob/main/index/resolver.go#L446 Is the issue, the hard limit of 100 levels deep of recursion, it too limited for this spec, so it throws up false positives, thinking they are circles, when really they are just very, very deeply nested.

daveshanley commented 6 months ago

This was fixed with the release v0.14