-
-
Notifications
You must be signed in to change notification settings - Fork 483
Description
We are parsing a bunch of 3rd party openapi specs, not all are perfectly valid.. We came across the following example today:
"ReplicationSnapshotInfo": {
"type": "object",
"required": [
"snappableId",
"snapshotId"
],
.....
"childSnapshotInfos": {
"type": "array",
"description": "An array of child snapshots information.",
"items": {
"$ref": "#/definitions/ReplicationSnapshotInfo"
}
}
}
},Where ReplicationSnapshotInfo is defined in terms of itself.
(See the original file here https://rubrikinc.github.io/api-doc-internal-6.0/openapi.json, line 28681, to reproduce in context)
When childSnapshotInfos was removed from this section, the parser works as expected, when its there, it goes into an infinite recursion and never halts.
I think it shouldn't be difficult for the parser to recognize such recursion by keeping a "visited" set, and checking that we are not recursing into something we already recursed in higher up the stack. Otherwise, as a plain user of this client, I don't know how else to avoid this, short of making a simplified parser that only looks for these loopy definitions..
Thing is that this runs on its own on many such files, so we can't manually inspect each (we couldn't even if we wanted to), and it just freezes our process without any way to recover.