encode / apistar

The Web API toolkit. 🛠
https://docs.apistar.com
BSD 3-Clause "New" or "Revised" License
5.57k stars 411 forks source link

Encoding a Type to JSON fails giving RecursionError #586

Closed faheel closed 6 years ago

faheel commented 6 years ago

I have the following types declared:

class Uploader(types.Type):
    channel_id = validators.String(title='ID')
    name = validators.String(title='Name')
    thumbnail_url = validators.String(title='Thumbnail URL')
    is_verified = validators.Boolean(title='Verified')

class Statistics(types.Type):
    views = validators.Integer(title='Views')
    likes = validators.Integer(title='Likes')
    dislikes = validators.Integer(title='Dislikes')

class Video(types.Type):
    video_id = validators.String(title='ID')
    title = validators.String(title='Title')
    upload_date = validators.String(title='Upload date', format='date')
    duration = validators.String(title='Duration')
    description = validators.String(title='Description')
    thumbnail_url = validators.String(title='Thumbnail URL')
    genre = validators.String(title='Genre')
    is_paid = validators.Boolean(title='Paid')
    is_unlisted = validators.Boolean(title='Unlisted')
    is_family_friendly = validators.Boolean(title='Family-friendly')
    uploader = Uploader
    statistics = Statistics

I have a Video object named video, and after setting all its values, when I return a http.JSONResponse containing it:

return http.JSONResponse(video)

I get the following error:

RecursionError: maximum recursion depth exceeded in comparison

which probably occurs when video is internally being encoded to JSON: screenshot-2018-6-16 2

tomchristie commented 6 years ago

Closed via #571. Release coming shortly.