Type error when creating a new secret #840

Closed
opened 2025-12-29 16:26:14 +01:00 by adam · 1 comment
Owner

Originally created by @gb1035 on GitHub (Apr 6, 2017).

Issue type: Bug Report

Python version: 2.7.9
NetBox version:2.0-beta2

When adding a new secret I get a server error screen. I am using the superuser account currently.

Steps:

  1. Selected a device
  2. Add secret
  3. Selected role
  4. Enter secret
  5. Submit
  6. Received error screen

Below is the traceback from running in debug mode.

Performing system checks...

System check identified no issues (0 silenced).
April 06, 2017 - 01:41:36
Django version 1.11, using settings 'netbox.settings'
Starting development server at http://0.0.0.0:8002/
Quit the server with CONTROL-C.
Internal Server Error: /dcim/devices/9/add-secret/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/opt/netbox-2.0-beta2/netbox/secrets/decorators.py", line 22, in wrapped_view
    return view(request, *args, **kwargs)
  File "/opt/netbox-2.0-beta2/netbox/secrets/views.py", line 83, in secret_add
    session_key = base64.b64decode(request.COOKIES.get('session_key', None))
  File "/usr/lib/python2.7/base64.py", line 73, in b64decode
    return binascii.a2b_base64(s)
TypeError: must be string or buffer, not None
[06/Apr/2017 01:41:47] "POST /dcim/devices/9/add-secret/ HTTP/1.1" 500 85437

Looking at my cookies for the site I do have a 'sessionid' cookie but not a 'session_key' cookie.

Originally created by @gb1035 on GitHub (Apr 6, 2017). <!-- Please note: GitHub issues are to be used only for feature requests and bug reports. For installation assistance or general discussion, please join us on the mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please indicate "bug report" or "feature request" below. Be sure to search the existing set of issues (both open and closed) to see if a similar issue has already been raised. --> ### Issue type: Bug Report <!-- If filing a bug, please indicate the version of Python and NetBox you are running. (This is not necessary for feature requests.) --> **Python version: 2.7.9** **NetBox version:2.0-beta2** <!-- If filing a bug, please record the exact steps taken to reproduce the bug and any errors messages that are generated. If filing a feature request, please precisely describe the data model or workflow you would like to see implemented, and provide a use case. --> When adding a new secret I get a server error screen. I am using the superuser account currently. Steps: 1. Selected a device 2. Add secret 3. Selected role 4. Enter secret 5. Submit 6. Received error screen Below is the traceback from running in debug mode. ``` Performing system checks... System check identified no issues (0 silenced). April 06, 2017 - 01:41:36 Django version 1.11, using settings 'netbox.settings' Starting development server at http://0.0.0.0:8002/ Quit the server with CONTROL-C. Internal Server Error: /dcim/devices/9/add-secret/ Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "/opt/netbox-2.0-beta2/netbox/secrets/decorators.py", line 22, in wrapped_view return view(request, *args, **kwargs) File "/opt/netbox-2.0-beta2/netbox/secrets/views.py", line 83, in secret_add session_key = base64.b64decode(request.COOKIES.get('session_key', None)) File "/usr/lib/python2.7/base64.py", line 73, in b64decode return binascii.a2b_base64(s) TypeError: must be string or buffer, not None [06/Apr/2017 01:41:47] "POST /dcim/devices/9/add-secret/ HTTP/1.1" 500 85437 ``` Looking at my cookies for the site I do have a 'sessionid' cookie but not a 'session_key' cookie.
adam added the type: bug label 2025-12-29 16:26:14 +01:00
adam closed this issue 2025-12-29 16:26:15 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 6, 2017):

The root cause here is that we attempt to base64-decode the session key even if it's None. The larger issue is that we don't prompt the user to acquire a session key before attempting to add/edit a secret.

@jeremystretch commented on GitHub (Apr 6, 2017): The root cause here is that we attempt to base64-decode the session key even if it's `None`. The larger issue is that we don't prompt the user to acquire a session key before attempting to add/edit a secret.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#840