Skip to content

Take into account that 'null' as a value for details is a valid JSON #2670

Closed
@karlcow

Description

@karlcow

@miketaylr Current staging is crashing on reporting issue.

[2018-10-24 06:14:13,421] INFO in views: 210.194.43.135 http://14.3.0.example.com/
Traceback (most recent call last):
  File "/home/webcompat/staging.webcompat.com/env/local/lib/python2.7/site-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/webcompat/staging.webcompat.com/env/local/lib/python2.7/site-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/home/webcompat/staging.webcompat.com/env/local/lib/python2.7/site-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/webcompat/staging.webcompat.com/env/local/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/webcompat/staging.webcompat.com/env/local/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/webcompat/staging.webcompat.com/env/local/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/webcompat/staging.webcompat.com/env/local/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/webcompat/staging.webcompat.com/env/local/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "./webcompat/views.py", line 242, in create_issue
    json_response = report_issue(form, proxy=True)
  File "./webcompat/issues.py", line 31, in report_issue
    data=json.dumps(build_formdata(form)))
  File "./webcompat/form.py", line 357, in build_formdata
    body += build_details(details)
  File "./webcompat/form.py", line 161, in build_details
    console_logs = content.pop('consoleLog', None)
AttributeError: 'NoneType' object has no attribute 'pop'

This is what is breaking it.

console_logs = None
content = details
try:
content = json.loads(details)
console_logs = content.pop('consoleLog', None)
except ValueError:
# if we got a ValueError, details was a string, so just pass it
# into get_details below
pass

This was written for solving issue #2653 with the request #2658

So basically we get an issue when the content is None

json.loads(details) might return None. We need to find out why.

One way to have a more robust way of doing things here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions