baranbartu/onthefly

TypeError: the JSON object must be str, bytes or bytearray, not 'NoneType'

jayvdb opened this issue · 1 comments

This is not happening locally in dev, but is happening on production - both are using redis:alpine docker. It appears to be occurring for any setting, and there are no stored settings yet. Two different places where it occurs.

  File "/usr/local/lib/python3.6/site-packages/oscar/apps/dashboard/menu.py", line 14, in get_nodes
    all_nodes = create_menu(settings.OSCAR_DASHBOARD_NAVIGATION)
  File "/usr/local/src/django-onthefly/onthefly/monkey_patch.py", line 19, in __getattr__
    return self.backend.get_value(name)
  File "/usr/local/src/django-onthefly/onthefly/backend/__init__.py", line 58, in get_value
    value = self.get(name)
  File "/usr/local/src/django-onthefly/onthefly/backend/redis_backend.py", line 17, in get
    return json.loads(dumped)
  File "/usr/local/lib/python3.6/json/__init__.py", line 348, in loads
    'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'NoneType'
[04:49:56][ERROR] django.request log.py:log_response:228 | Internal Server Error: /admin/onthefly-settings/
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/contrib/admin/sites.py", line 223, in inner
    return view(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 158, in get
    context = self.get_context_data(**kwargs)
  File "/usr/local/src/django-onthefly/onthefly/admin.py", line 20, in get_context_data
    'onthefly_settings': settings.get_onthefly_settings
  File "/usr/local/src/django-onthefly/onthefly/monkey_patch.py", line 36, in get_onthefly_settings
    return self.backend.values()
  File "/usr/local/src/django-onthefly/onthefly/backend/redis_backend.py", line 37, in values
    all_values[field] = json.loads(values[i])
  File "/usr/local/lib/python3.6/json/__init__.py", line 348, in loads
    'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'NoneType'

git grep --context 4 ONTHEFLY settings.py

REDIS_ENDPOINT = 'redis:6379'
if 'onthefly' in INSTALLED_APPS:
    ONTHEFLY = {
        'BACKEND': 'onthefly.backend.redis_backend.RedisBackend',
        'OPTIONS': {'URL': f'redis://{REDIS_ENDPOINT}/15'},
    }

hi @jayvdb . sorry for inconvenience. I've been busy over the last month and just saw your contributions. I have merged your pull requests. Thanks.