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

"Invalid data" error on certain nested API serializers #2310

Closed
jeremystretch opened this issue Aug 6, 2018 · 0 comments
Closed

"Invalid data" error on certain nested API serializers #2310

jeremystretch opened this issue Aug 6, 2018 · 0 comments
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.5.2
  • NetBox version: 2.4.0

Steps to Reproduce

This is an extension of the issue reported in #2299 during the v2.4 beta. Several nested API serializers have been identified as improperly handling posted data. Specifically, they expect a dictionary representation of an object rather than an integer (primary key). For example:

curl -X PATCH \
-H "Authorization: Token <TOKEN>" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://localhost:8000/api/dcim/devices/<pk>/ \
--data '{"cluster": 123}'

The following models and fields have been identified as affected by this bug:

  • Device: cluster, primary_ip4, primary_ip6, virtual_chassis
  • VirtualMachine: primary_ip4, primary_ip6

Expected Behavior

The device should be assigned to the specified cluster.

Observed Behavior

The request yields the following validation error:

{
    "cluster": {
        "non_field_errors": [
            "Invalid data. Expected a dictionary, but got int."
        ]
    }
}
@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation labels Aug 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
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