wagtail-deprecated / wagtail-react-streamfield

Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)
https://wagtail.github.io/react-streamfield/public/
BSD 3-Clause "New" or "Revised" License
74 stars 23 forks source link

Page Preview - TypeError: the JSON object must be str, bytes or bytearray, not NoneType #67

Closed cspollar closed 3 years ago

cspollar commented 3 years ago

I have 3 users using IE 11.0 on Windows 10 which throw a TypeError: the JSON object must be str, bytes or bytearray, not NoneType when previewing the page.

The key issue is 'body' missing from the data dict. Body is not a required field, but for some reason value_from_datadict attempts to get the nonexistent value and returns None.

stream_field_data = json.loads(data.get(name))

I haven't been able to reproduce the issue on my Mac running Chrome (Version 86.0.4240.111). I wonder if there is something the users are doing that is unique to IE (similar to https://github.com/wagtail/wagtail/issues/1697).

Version Info:

TypeError: the JSON object must be str, bytes or bytearray, not NoneType
  File "django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "wagtail/admin/urls/__init__.py", line 109, in wrapper
    return view_func(request, *args, **kwargs)
  File "wagtail/admin/auth.py", line 188, in decorated_view
    return view_func(request, *args, **kwargs)
  File "django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "wagtail/admin/views/pages.py", line 664, in post
    return JsonResponse({'is_valid': form.is_valid()})
  File "modelcluster/forms.py", line 316, in is_valid
    form_is_valid = super(ClusterForm, self).is_valid()
  File "django/forms/forms.py", line 185, in is_valid
    return self.is_bound and not self.errors
  File "django/forms/forms.py", line 180, in errors
    self.full_clean()
  File "django/forms/forms.py", line 381, in full_clean
    self._clean_fields()
  File "django/forms/forms.py", line 393, in _clean_fields
    value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name))
  File "wagtail_react_streamfield/widgets.py", line 118, in value_from_datadict
    stream_field_data = json.loads(data.get(name))
  File "json/__init__.py", line 341, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '

Data Dict:

{
'category': '4', 
'csrfmiddlewaretoken': 'BMXpuFNNRsb8V9xDrFK5VEBihRdwxoWpTQwOO516u7MJhDcSi6tmHD0AYktheKXa', 
'date': '2020-11-03', 
'expire_at': '', 
'go_live_at': '', 
'image': '1259', 
'next': '', 
'search_description': '', 
'seo_title': '', 
'sidebar': '[]', 
'slug': 'a-great-title, 
'tags': '', 
'title': 'A Great Title'
}
cspollar commented 3 years ago

The enhancements in core Wagtail have allowed me to no-longer need this package. :sunglasses: