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

OPTIONS requests for list API endpoints raises an exception #5470

Closed
jeremystretch opened this issue Dec 16, 2020 · 0 comments
Closed

OPTIONS requests for list API endpoints raises an exception #5470

jeremystretch opened this issue Dec 16, 2020 · 0 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@jeremystretch
Copy link
Member

Environment

  • Python version: 3.6.9
  • NetBox version: 2.10.0

Steps to Reproduce

  1. Make an OPTIONS request to a REST API list endpoint. For example:
curl -X OPTIONS \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://netbox/api/dcim/devices/

(Note that all REST API endpoints are affected, not just the one above.)

Expected Behavior

The response should return metadata for the endpoint. An example is below.

{
    "name": "Device",
    "description": "",
    "renders": [
        "application/json",
        "text/html"
    ],
    "parses": [
        "application/json",
        "application/x-www-form-urlencoded",
        "multipart/form-data"
    ],
    "actions": {
        "POST": {
...

Observed Behavior

An exception is raised:

Exception Type: AssertionError at /api/dcim/devices/
Exception Value: Expected view DeviceViewSet to be called with a URL keyword argument named "pk". Fix your URL conf, or set the `.lookup_field` attribute on the view correctly.

It appears that the introduction of bulk update support poses a problem when rendering metadata for the endpoint, since the metadata class calls get_object() when evaluating fields for POST and PUT requests.

@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation labels Dec 16, 2020
@jeremystretch jeremystretch self-assigned this Dec 16, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

1 participant