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

Most upvoted comments

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:

commit 8126ee94e1e178bbfd5561ac4d502d08446f47aa
Merge: 82475a1 4d6f851
Author: Ivan Porto Carrero <ivan@flanders.co.nz>
Date:   Tue Jul 10 11:57:44 2018 -0700

    Merge pull request #1615 from fredbi/fix-1614-circular-in-response
    
    Fixes #1614

commit 4d6f851c3aeddb0548bc8aeeb84c2aae60a8a27a
Author: fredbi <frederic.bidon@advisam.consulting>
Date:   Tue Jul 10 19:59:35 2018 +0200

    Fixes #1614

OK so I admit the new go-openapi/analysis/Flatten() is pickier than it should:

responses:
  blah:
    description: "blah"

is a valid candidate for a schema after all, when:

responses:
  booh:
    description: "booh"
    schema:
       type: string

is not

I might change the Flatten() to attempt to unmarshall again as a schema. Any thought?