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

[BUG] $ref resolution fails for OpenAPI spec on schemathesis 3.18.3 #1697

Open
2 tasks done
jmidt opened this issue Feb 16, 2023 · 1 comment
Open
2 tasks done

[BUG] $ref resolution fails for OpenAPI spec on schemathesis 3.18.3 #1697

jmidt opened this issue Feb 16, 2023 · 1 comment
Assignees
Labels
Status: Needs Design Issue requires more design work Type: Bug Errors or unexpected behavior

Comments

@jmidt
Copy link

jmidt commented Feb 16, 2023

Checklist

Describe the bug
Including the OpenAPI spec itself in the spec causes Schemathesis to run forever in the resolve_all() step of the schema parsing. This would be a use case if you supply your own API spec through your API, and note the OpenAPI spec as the schema.

To Reproduce
Steps to reproduce the behavior:

  • Use the API spec below.
  • Read the file with schema = schemathesis.from_path(file_path)
  • Accessing e.g. schema["/"] will cause schemathesis to hang forever in the resolve_all() step, consuming more and more memory. I let it run up to at least 30G of memory consumed with no sign of continuing.
{
    openapi: 3.0.3
    info:
      version: 1.0.0
      title: My API
      description: My HTTP interface.
    
    paths:
      # Get this specification
      /:
        get:
          summary: OpenAPI description (this document)
          tags:
            - Introspection
          operationId: getApiDescription
          responses:
            "200":
              description: OK
              content:
                application/openapi+json:
                  schema:
                    $ref: "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/aa91a19c43f8a12c02efa42d64794e396473f3b1/schemas/v3.0/schema.json#"
}

Expected behavior
I would expect schemathesis to be able to parse the OpenAPI spec itself.

Environment (please complete the following information):

  • OS: Ubuntu
  • Python version: 3.10
  • Schemathesis version: 3.18.3
  • Spec version: 3.0.3

Additional context
It worked on Schemathesis 3.15.6.

@jmidt jmidt added Status: Needs Triage Requires initial assessment to categorize and prioritize Type: Bug Errors or unexpected behavior labels Feb 16, 2023
@Stranger6667 Stranger6667 removed the Status: Needs Triage Requires initial assessment to categorize and prioritize label Oct 11, 2023
@Stranger6667
Copy link
Member

Indeed, it is bad behavior - I'll investigate what's the root cause. In some cases, we fallback to inlining schemas up to some recursion level as hypothesis-jsonschema does not yet support recursive references. Implementing it properly is on my todo list for the next following months (as it is needed to support Open API 3.1 properly), so implementing this will solve one of the possible causes.

@Stranger6667 Stranger6667 added Status: Needs more info Proceeding requires additional info from the author Status: Needs Design Issue requires more design work and removed Status: Needs more info Proceeding requires additional info from the author labels Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Design Issue requires more design work Type: Bug Errors or unexpected behavior
Projects
None yet
Development

No branches or pull requests

2 participants