Skip to content

[BUG][python-experimental] RecursionError: maximum recursion depth exceeded while getting the str of an object #12151

Closed

Description

@MAKOMO

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

On using the Python client generated with python-experimental I receive the following exception.

>>> api_instance.authenticate(credentials)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dataclasses.py", line 405, in wrapper
    result = user_function(self)
  File "<string>", line 3, in __repr__
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/frozendict-2.3.1-py3.10.egg/frozendict/core.py", line 90, in __repr__
    body = super().__repr__(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/schemas.py", line 497, in __repr__
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/schemas.py", line 497, in __repr__
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/schemas.py", line 497, in __repr__
  [Previous line repeated 245 more times]
RecursionError: maximum recursion depth exceeded while getting the str of an object
openapi-generator version

current trunk

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: test
  version: 0.0.1
tags:
  - name: account
servers:
  - url: https://localhost:62602/api/v1
paths:
  /accounts/users/authenticate:
    post:
      operationId: authenticate
      tags:
        - account
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Credentials"
      responses:
        "200":
          description: Success
          content:
            "application/json":
              schema:
                $ref: "#/components/schemas/SuccessAuthentication"
        default:
          description: unexpected error response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
components:
  schemas:
    Credentials:
      type: object
      description: user credentials
      properties:
        email:
          type: string
        password:
          type: string
          format: password
      required:
        - email
        - password
    Error:
      type: object
      properties:
        error:
          type: string
    SuccessAuthentication:
      type: object
      properties:
        success:
          type: boolean
Generation Details

I compiled the trunk using

# cd openapi-generator
# ./mvnw -Dmaven.test.skip=true clean install

and generated the client from the YAML specification above using

java -jar openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ../../bug.yaml -g python-experimental -o ../../_build/client/

compiled and installed the Python client using

# cd _build/client
# sudo python3 setup.py install
Steps to reproduce

Using pook to simulate the server response:

# python3
Python 3.10.4 (v3.10.4:9d38120e33, Mar 23 2022, 17:29:05) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pook
>>> import urllib3
>>> import openapi_client
>>> from openapi_client.api import account_api
>>> from openapi_client.model.credentials import Credentials
>>> from openapi_client.model.error import Error
>>> from openapi_client.model.success_authentication import SuccessAuthentication
>>> configuration = openapi_client.Configuration(
...     host = "https://localhost:62602/api/v1"
... )
>>> api_client = openapi_client.ApiClient(configuration)
>>> api_instance = account_api.AccountApi(api_client)
>>> credentials = Credentials(
...     email = "user@mail.com",
...     password = "geheim",
... )
>>> pook.on()
>>> pook.post('https://localhost:62602/api/v1/accounts/users/authenticate',
...       response_type='application/json',
...       response_json={"success":True}).reply(200)
Response(
    headers=HTTPHeaderDict({'Content-Type': 'application/json'}),
    status=200,
    body={
    "success": true
}
)
>>> api_instance.authenticate(credentials)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dataclasses.py", line 405, in wrapper
    result = user_function(self)
  File "<string>", line 3, in __repr__
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/frozendict-2.3.1-py3.10.egg/frozendict/core.py", line 90, in __repr__
    body = super().__repr__(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/schemas.py", line 497, in __repr__
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/schemas.py", line 497, in __repr__
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/schemas.py", line 497, in __repr__
  [Previous line repeated 245 more times]
RecursionError: maximum recursion depth exceeded while getting the str of an object

Same error without using pook addressing a server running on localhost returning the mocked response.

Related issues/PRs
Suggest a fix

Sorry

Activity

  1. changed the title [-][BUG][python-experimental] RecursionError: maximum recursion depth exceeded while getting the str of an object[/-] [+][BUG][python][python-experimental] RecursionError: maximum recursion depth exceeded while getting the str of an object[/+] on Apr 16, 2022
  2. changed the title [-][BUG][python][python-experimental] RecursionError: maximum recursion depth exceeded while getting the str of an object[/-] [+][BUG][python-experimental] RecursionError: maximum recursion depth exceeded while getting the str of an object[/+] on Apr 16, 2022
  3. spacether commented on Apr 17, 2022

    @spacether
    Contributor

    @MAKOMO this bug is fixed if you use the latest master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions