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

serialize causing: AttributeError: 'NoneType' object has no attribute 'split' #346

Closed
jpmateo022 opened this issue Jan 29, 2021 · 8 comments
Labels
needs more info This is a ticket that requires more information from the author

Comments

@jpmateo022
Copy link

Have anyone experiencing this? It seems it happens in serialize function

Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/gunicorn/workers/gthread.py", line 271, in handle
keepalive = self.handle_request(req, conn)
File "/usr/local/lib/python3.8/dist-packages/gunicorn/workers/gthread.py", line 320, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/usr/local/lib/python3.8/dist-packages/whitenoise/base.py", line 86, in call
return self.application(environ, start_response)
File "/usr/local/lib/python3.8/dist-packages/masonite/wsgi.py", line 42, in response_handler
start_response(response.get_status_code(), response.get_and_reset_headers())
File "/usr/local/lib/python3.8/dist-packages/gunicorn/http/wsgi.py", line 239, in start_response
self.status_code = int(self.status.split()[0])
AttributeError: 'NoneType' object has no attribute 'split'

@jpmateo022 jpmateo022 changed the title AttributeError: 'NoneType' object has no attribute 'split' serialize causing: AttributeError: 'NoneType' object has no attribute 'split' Jan 29, 2021
@Marlysson
Copy link
Contributor

Which query are you using before the call of serialize function?

@josephmancuso
Copy link
Member

This doesn't look like an issue with the orm but an issue with Masonite setting the response code. Can we see a code example of your controller method?

@jpmateo022
Copy link
Author

Hi, sorry late reply. This is what I'm calling after the query.

            return response.json({
                'code': 200,
                'message': 'Success',
                'data': data
            },200)

@josephmancuso
Copy link
Member

@Marlysson can you replicate this? This doesn't throw that error. It looks as if the response cannot get a status. in Masonite. If anything it looks like a Masonite issue

File "/usr/local/lib/python3.8/dist-packages/masonite/wsgi.py", line 42, in response_handler
start_response(response.get_status_code(), response.get_and_reset_headers())

@Marlysson
Copy link
Contributor

Sure. I'll try this.

@jpmateo022
Copy link
Author

Thanks Guys :)

@Marlysson
Copy link
Contributor

Marlysson commented Jan 30, 2021

I can't replicate this error. @jpmateo022 Can you provide more about your workflow until the final response?

With this snippet everything works fine:

bulk = [{
    "age": 15,
    "is_admin": False,
    "role": "TEST"
},
{
    "age": 25,
    "is_admin": True,
    "role": "DEVELOPER",
},
{
    "age": 12,
    "is_admin": False,
    "role": "SUPERVISOR",
}]

Model.bulk_create(bulk)

data = Model.all().serialize()

return response.json({
    'code': 200,
    'message': 'Success',
    'data': data
},200)

@josephmancuso josephmancuso added the needs more info This is a ticket that requires more information from the author label Jan 31, 2021
@jpmateo022
Copy link
Author

jpmateo022 commented Feb 1, 2021

Hi, I'm moving this to the masonite framework.

MasoniteFramework/masonite#413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This is a ticket that requires more information from the author
Projects
None yet
Development

No branches or pull requests

3 participants