API endpoint throwing AttributeError #3277

Closed
opened 2025-12-29 18:27:23 +01:00 by adam · 7 comments
Owner

Originally created by @EppO on GitHub (Feb 5, 2020).

Environment

  • Python version: 3.6.6
  • NetBox version: v2.7.5-dev (32623148)

Steps to Reproduce

  1. Upgrade netbox to 32623148
  2. Run upgrade.sh script
  3. Go to https://netbox-url/api

Expected Behavior

See API Root page

Observed Behavior

Error 500 is thrown

Internal Server Error: /api/
Traceback (most recent call last):
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/django/core/handlers/base.py", line 145, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/django/core/handlers/base.py", line 143, in _get_response
    response = response.render()
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/django/template/response.py", line 106, in render
    self.content = self.rendered_content
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/response.py", line 70, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/renderers.py", line 725, in render
    context = self.get_context(data, accepted_media_type, renderer_context)
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/renderers.py", line 687, in get_context
    'description': self.get_description(view, response.status_code),
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/renderers.py", line 602, in get_description
    return view.get_view_description(html=True)
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/views.py", line 245, in get_view_description
    return func(self, html)
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/views.py", line 61, in get_view_description
    return formatting.markup_description(description)
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/utils/formatting.py", line 63, in markup_description
    description = apply_markdown(description)
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/compat.py", line 156, in apply_markdown
    md_filter_add_syntax_highlight(md)
  File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/compat.py", line 213, in md_filter_add_syntax_highlight
    md.preprocessors.register(CodeBlockPreprocessor(), 'highlight', 40)
AttributeError: 'OrderedDict' object has no attribute 'register'
Originally created by @EppO on GitHub (Feb 5, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.6.6 * NetBox version: v2.7.5-dev (32623148) <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a wrapper like pynetbox. --> ### Steps to Reproduce 1. Upgrade netbox to 32623148 2. Run upgrade.sh script 3. Go to https://netbox-url/api <!-- What did you expect to happen? --> ### Expected Behavior See API Root page <!-- What happened instead? --> ### Observed Behavior Error 500 is thrown ```python Internal Server Error: /api/ Traceback (most recent call last): File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/django/core/handlers/base.py", line 145, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/django/core/handlers/base.py", line 143, in _get_response response = response.render() File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/django/template/response.py", line 106, in render self.content = self.rendered_content File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/response.py", line 70, in rendered_content ret = renderer.render(self.data, accepted_media_type, context) File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/renderers.py", line 725, in render context = self.get_context(data, accepted_media_type, renderer_context) File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/renderers.py", line 687, in get_context 'description': self.get_description(view, response.status_code), File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/renderers.py", line 602, in get_description return view.get_view_description(html=True) File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/views.py", line 245, in get_view_description return func(self, html) File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/views.py", line 61, in get_view_description return formatting.markup_description(description) File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/utils/formatting.py", line 63, in markup_description description = apply_markdown(description) File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/compat.py", line 156, in apply_markdown md_filter_add_syntax_highlight(md) File "/home/netbox_service/netbox_env/lib/python3.6/site-packages/rest_framework/compat.py", line 213, in md_filter_add_syntax_highlight md.preprocessors.register(CodeBlockPreprocessor(), 'highlight', 40) AttributeError: 'OrderedDict' object has no attribute 'register' ```
adam closed this issue 2025-12-29 18:27:23 +01:00
Author
Owner

@jeremystretch commented on GitHub (Feb 5, 2020):

Please do not open bugs against the develop branch. It is not guaranteed to be stable at any point in time. If you are not actively engaged in developing NetBox, you should be running the master branch only.

@jeremystretch commented on GitHub (Feb 5, 2020): Please do not open bugs against the `develop` branch. It is not guaranteed to be stable at any point in time. If you are not actively engaged in developing NetBox, you should be running the `master` branch only.
Author
Owner

@EppO commented on GitHub (Feb 5, 2020):

I just checked out v2.7.2 (e13d4ffe60) and I hit the same issue

@EppO commented on GitHub (Feb 5, 2020): I just checked out v2.7.2 (e13d4ffe607ad73b34d08f1cc3af58af19acb445) and I hit the same issue
Author
Owner

@EppO commented on GitHub (Feb 5, 2020):

also tried with v2.7.4

@EppO commented on GitHub (Feb 5, 2020): also tried with v2.7.4
Author
Owner

@EppO commented on GitHub (Feb 5, 2020):

going back to 2.6.12 release fixes the issue. Please reopen this, I really think there is something fishy

@EppO commented on GitHub (Feb 5, 2020): going back to 2.6.12 release fixes the issue. Please reopen this, I really think there is something fishy
Author
Owner

@jeremystretch commented on GitHub (Feb 5, 2020):

This seems to be a problem with your installation as I cannot reproduce it on a stock release. You can quickly confirm this on the demo site, which is running v2.7.3. Please ensure that you have the proper version of each dependency installed with pip install -r requirements.txt, and post on the discussion list if you require any further assistance.

@jeremystretch commented on GitHub (Feb 5, 2020): This seems to be a problem with your installation as I cannot reproduce it on a stock release. You can quickly confirm this on [the demo site](https://netboxdemo.com/api/), which is running v2.7.3. Please ensure that you have the proper version of each dependency installed with `pip install -r requirements.txt`, and post on the discussion list if you require any further assistance.
Author
Owner

@EppO commented on GitHub (Feb 5, 2020):

Weird, I can confirm the issue comes up with djangorestframework==3.10.3 (starting from 3.10.0 actually), if I downgrade to djangorestframework==3.9.4, it works fine. I use the upgrade script every time I change the requirements.txt or upgrade netbox, so that takes care of the pip install.

@EppO commented on GitHub (Feb 5, 2020): Weird, I can confirm the issue comes up with `djangorestframework==3.10.3` (starting from 3.10.0 actually), if I downgrade to `djangorestframework==3.9.4`, it works fine. I use the upgrade script every time I change the requirements.txt or upgrade netbox, so that takes care of the pip install.
Author
Owner

@EppO commented on GitHub (Feb 5, 2020):

For the record, I fixed it by killing my virtual env and recreating it from scratch.

@EppO commented on GitHub (Feb 5, 2020): For the record, I fixed it by killing my virtual env and recreating it from scratch.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3277