go-swagger: Stack overflow error in swagger validate
When running swagger validate ./public/swagger.v1.json probably after #1608 was merged we are having error:
runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow
For more details see: https://drone.gitea.io/go-gitea/gitea/1918/8
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 29 (26 by maintainers)
Commits related to this issue
- Fixes #1614 — committed to fredbi/go-swagger by fredbi 6 years ago
- Fixes #1614 — committed to fredbi/go-swagger by fredbi 6 years ago
- Merge pull request #1615 from fredbi/fix-1614-circular-in-response Fixes #1614 — committed to go-swagger/go-swagger by casualjim 6 years ago
- Improves behavior in edge cases where schemas points to responses or parameters. This makes the flatten behavior consistent with swagger validate. * now unmarshalls the struct as a schema: if this w... — committed to fredbi/analysis by fredbi 6 years ago
- Improvements to minimal flattening * fixes #1621 * improves #1602 and #1614 (flatten consistent with validate regarding pointers to responses/parameters as schemas) — committed to fredbi/go-swagger by fredbi 6 years ago
- Fixes with remote and cyclical $ref * Fixes hang on cyclical $ref in responses or body params (required go-openapi/spec update) * Fixes errors when validating a spec with a relative path other than c... — committed to fredbi/validate by fredbi 6 years ago
- Fixes with remote and cyclical $ref * Fixes hang on cyclical $ref in responses or body params (required go-openapi/spec update) * Fixes errors when validating a spec with a relative path other than c... — committed to fredbi/validate by fredbi 6 years ago
- Fix flatten with pointers containing escaped chars (e.g. '{}' Fixed undue duplicate name detection when resolving remote refs Improves behavior in edge cases where schemas points to responses or par... — committed to fredbi/analysis by fredbi 6 years ago
- Fixes with remote and cyclical $ref * Fixes hang on cyclical $ref in responses or body params (required go-openapi/spec update) * Fixes errors when validating a spec with a relative path other than c... — committed to fredbi/validate by fredbi 6 years ago
- Improvements to minimal flattening * fixes #1621 (remote refs) * fixes #1614 (hang on validate) * improves #1602 and #1614 (flatten consistent with validate regarding pointers to responses/parameter... — committed to fredbi/go-swagger by fredbi 6 years ago
- Fix flatten with pointers containing escaped chars (e.g. '{}' Fixed undue duplicate name detection when resolving remote refs Improves behavior in edge cases where schemas points to responses or par... — committed to fredbi/analysis by fredbi 6 years ago
- Improvements to minimal flattening * fixes #1621 (remote refs) * fixes #1614 (hang on validate) * improves #1602 and #1614 (flatten consistent with validate regarding pointers to responses/parameter... — committed to fredbi/go-swagger by fredbi 6 years ago
- Fix flatten with pointers containing escaped chars (e.g. '{}' Fixed undue duplicate name detection when resolving remote refs Improves behavior in edge cases where schemas points to responses or par... — committed to fredbi/analysis by fredbi 6 years ago
- Improvements to minimal flattening * fixes #1621 (remote refs) * fixes #1614 (hang on validate) * improves #1602 and #1614 (flatten consistent with validate regarding pointers to responses/parameter... — committed to fredbi/go-swagger by fredbi 6 years ago
- Fixes with remote and cyclical $ref * Fixes hang on cyclical $ref in responses or body params (required go-openapi/spec update) * Fixes errors when validating a spec with a relative path other than c... — committed to fredbi/validate by fredbi 6 years ago
- Fixes with remote and cyclical $ref * Fixes hang on cyclical $ref in responses or body params (required go-openapi/spec update) * Fixes errors when validating a spec with a relative path other than c... — committed to fredbi/validate by fredbi 6 years ago
- Fixes with remote and cyclical $ref * Fixes hang on cyclical $ref in responses or body params (required go-openapi/spec update) * Fixes errors when validating a spec with a relative path other than c... — committed to fredbi/validate by fredbi 6 years ago
- Improvements to minimal flattening * fixes #1621 (remote refs) * fixes #1614 (hang on validate) * improves #1602 and #1614 (flatten consistent with validate regarding pointers to responses/parameter... — committed to fredbi/go-swagger by fredbi 6 years ago
- Improvements to minimal flattening * fixes #1621 (remote refs) * fixes #1614 (hang on validate) * improves #1602 and #1614 (flatten consistent with validate regarding pointers to responses/parameter... — committed to fredbi/go-swagger by fredbi 6 years ago
- Improvements to minimal flattening * fixes #1621 (remote refs) * fixes #1614 (hang on validate) * improves #1602 and #1614 (flatten consistent with validate regarding pointers to responses/parameter... — committed to fredbi/go-swagger by fredbi 6 years ago
Could reproduce now. It is a base path issue when resolving refs. Running validate in the same directory as the spec: all goes smoothly. Running it from another directory with relative path (e.g. swagger validate …/gitea.json) hangs
Problem is that go-openapi/validate uses spec.ExpandSchema(), that is, without BasePath, and the root defaults to cwd() in this case… This causes trouble when cyclic references remain in the expanded spec.
Built at this commit:
OK so I admit the new go-openapi/analysis/Flatten() is pickier than it should:
is a valid candidate for a schema after all, when:
is not
I might change the Flatten() to attempt to unmarshall again as a schema. Any thought?