Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception via malformed API request to /available-ips/ #14397

Closed
candlerb opened this issue Dec 1, 2023 · 0 comments · Fixed by #14433
Closed

Exception via malformed API request to /available-ips/ #14397

candlerb opened this issue Dec 1, 2023 · 0 comments · Fixed by #14433
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@candlerb
Copy link
Contributor

candlerb commented Dec 1, 2023

NetBox version

v3.6.6

Python version

3.8

Steps to Reproduce

  1. Get the ID of a prefix (in this case I'm using prefix 32)
  2. Use curl to make a POST API request with empty body but default Content-Type: application/x-www-form-urlencoded
curl -d '' -vsS -H "Authorization: Token $TOKEN" "$NETBOX/api/ipam/prefixes/32/available-ips/"

Expected Behavior

Request is either accepted (since the body of the request isn't used), or is validated and rejected with a well-formed 4xx response from the API

Observed Behavior

An exception is raised:

< HTTP/1.1 500 Internal Server Error
...
                            <p>
                                There was a problem with your request. Please contact an administrator.
                            </p>

                        <hr />
                        <p>
                            The complete exception is provided below:
                        </p>
<pre class="block"><strong>&lt;class &#x27;AttributeError&#x27;&gt;</strong><br />
This QueryDict instance is immutable

The backtrace is mailed out to ADMINS if this has been set up.

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/opt/netbox/venv/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/netbox/venv/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/netbox/venv/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/ipam/api/views.py", line 451, in post
    return super().post(request, pk)
  File "/opt/netbox/netbox/ipam/api/views.py", line 293, in post
    requested_objects = self.prep_object_data(requested_objects, available_objects, parent)
  File "/opt/netbox/netbox/ipam/api/views.py", line 434, in prep_object_data
    request_data.update({
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/utils/datastructures.py", line 211, in update
    self.setlistdefault(key).append(value)
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/http/request.py", line 584, in setlistdefault
    self._assert_mutable()
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/http/request.py", line 552, in _assert_mutable
    raise AttributeError("This QueryDict instance is immutable")

Exception Type: AttributeError at /api/ipam/prefixes/32/available-ips/
Exception Value: This QueryDict instance is immutable
Raised during: ipam.api.views.PrefixAvailableIPAddressesView
Request information:
USER: admin
@candlerb candlerb added the type: bug A confirmed report of unexpected behavior in the application label Dec 1, 2023
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: low Does not significantly disrupt application functionality, or a workaround is available labels Dec 5, 2023
@jeremystretch jeremystretch self-assigned this Dec 5, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
2 participants