Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular references in separate files results in stack overflow error #442

Open
jacobdekeizer opened this issue Nov 24, 2023 · 2 comments
Open
Labels
bug Something isn't working

Comments

@jacobdekeizer
Copy link

jacobdekeizer commented Nov 24, 2023

Describe the bug
We have an open api specification with circular references where each object is stored in a separate file. This results in a stack overflow error:

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0x140ade80340 stack=[0x140ade80000, 0x140cde80000]
fatal error: stack overflow

runtime stack:
runtime.throw({0x1048394c0?, 0x104347498?})

I am on the latest version and the pr #418 did not fix the issue for our scenario.

To Reproduce

I've made two example files based on the example files in pr #418:

circular2.yaml

openapi: 3.0.0
info:
    title: Circular Reference Example
    version: 1.0.0
paths:
    /sample:
        put:
            requestBody:
                required: true
                content:
                    application/json:
                        schema:
                            $ref: './AwsEnvironmentSettings.yaml'
            responses:
                '200':
                    description: Ok

AwsEnvironmentSettings.yaml

type: object
properties:
    children:
        type: array
        items:
            $ref: './AWSEnvironmentSettings.yaml'
description: test

Steps to reproduce the behavior:

  1. Create the 2 files above
  2. oasdiff breaking ./circular2.yaml ./circular2.yaml
@jacobdekeizer jacobdekeizer added the bug Something isn't working label Nov 24, 2023
@jacobdekeizer jacobdekeizer changed the title Circular references in separate files Circular references in separate files results in stack overflow error Nov 24, 2023
@reuvenharrison
Copy link
Collaborator

reuvenharrison commented Nov 24, 2023

Looks like a problem in underlying kin-openapi
This can be used to replicate with your files above:

func TestLoadCircular(t *testing.T) {
	loader := NewLoader()
	loader.IsExternalRefsAllowed = true
	_, err := loader.LoadFromFile("testdata/circular2.yaml")
	require.NoError(t, err)
}

Thanks for reporting!

@anikitin
Copy link

anikitin commented Mar 9, 2024

I faced the same issue recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants