Netbox api call /dcim/devices/ virtual chassis does not have "member_count" #6467

Closed
opened 2025-12-29 19:41:03 +01:00 by adam · 7 comments
Owner

Originally created by @PaulWestphal on GitHub (May 10, 2022).

NetBox version

v3.2.2

Python version

3.8

Steps to Reproduce

  1. Create any number of devices and a virtual chassis.
  2. Add the devices to the virtual chassis.
  3. Send a GET HTTP request to http://netbox-address-here/api/dcim/devices/

Expected Behavior

According to the documentation, the "virtual_chassis" of each of the created devices should have a field "member_count".

Observed Behavior

There is no "member_count".

Originally created by @PaulWestphal on GitHub (May 10, 2022). ### NetBox version v3.2.2 ### Python version 3.8 ### Steps to Reproduce 1. Create any number of devices and a virtual chassis. 2. Add the devices to the virtual chassis. 3. Send a GET HTTP request to http://netbox-address-here/api/dcim/devices/ ### Expected Behavior According to the documentation, the "virtual_chassis" of each of the created devices should have a field "member_count". ### Observed Behavior There is no "member_count".
adam closed this issue 2025-12-29 19:41:03 +01:00
Author
Owner

@DanSheps commented on GitHub (May 10, 2022):

You need to query the virtual chassis, not the device.

@DanSheps commented on GitHub (May 10, 2022): You need to query the virtual chassis, not the device.
Author
Owner

@DanSheps commented on GitHub (May 10, 2022):

Thank you for opening a bug report. It seems that the described functionality is intended behavior. If you meant to open a feature request instead, please close this issue and open a new one using the feature request template. Otherwise, please revise your post above to elaborate on why you believe the observed behavior is flawed.

@DanSheps commented on GitHub (May 10, 2022): Thank you for opening a bug report. It seems that the described functionality is intended behavior. If you meant to open a feature request instead, please close this issue and open a new one using the [feature request template](https://github.com/netbox-community/netbox/issues/new?template=feature_request.md). Otherwise, please revise your post above to elaborate on why you believe the observed behavior is flawed.
Author
Owner

@PaulWestphal commented on GitHub (May 10, 2022):

The example value from /dcim/devices/ has the member_count in it. You can check the documentation yourself.

{

  "count": 0,

  "next": "string",

  "previous": "string",

  "results": [

    {

      "id": 0,

      "url": "string",

      "display": "string",

      "name": "string",

      "device_type": {

        "id": 0,

        "url": "string",

        "display": "string",

        "manufacturer": {

          "id": 0,

          "url": "string",

          "display": "string",

          "name": "string",

          "slug": "string",

          "devicetype_count": 0

       [...]

      "virtual_chassis": {

        "id": 0,

        "url": "string",

        "display": "string",

        "name": "string",

        "master": {

          "id": 0,

          "url": "string",

          "display": "string",

          "name": "string"

        },

        "member_count": 0  <-----------

      },

      "vc_position": 0,

      "vc_priority": 0,

      "comments": "string",

      "local_context_data": "string",

     [...]

      },

      "created": "2022-05-10T14:42:55.190Z",

      "last_updated": "2022-05-10T14:42:55.190Z"

    }

  ]

}

@PaulWestphal commented on GitHub (May 10, 2022): The example value from /dcim/devices/ has the member_count in it. You can check the documentation yourself. ``` { "count": 0, "next": "string", "previous": "string", "results": [ { "id": 0, "url": "string", "display": "string", "name": "string", "device_type": { "id": 0, "url": "string", "display": "string", "manufacturer": { "id": 0, "url": "string", "display": "string", "name": "string", "slug": "string", "devicetype_count": 0 [...] "virtual_chassis": { "id": 0, "url": "string", "display": "string", "name": "string", "master": { "id": 0, "url": "string", "display": "string", "name": "string" }, "member_count": 0 <----------- }, "vc_position": 0, "vc_priority": 0, "comments": "string", "local_context_data": "string", [...] }, "created": "2022-05-10T14:42:55.190Z", "last_updated": "2022-05-10T14:42:55.190Z" } ] } ```
Author
Owner

@DanSheps commented on GitHub (May 10, 2022):

You are correct, it is on the serializer.

I am currently looking into this as it may be related to the field not being annotated when the query resolves.

@DanSheps commented on GitHub (May 10, 2022): You are correct, it is on the serializer. I am currently looking into this as it may be related to the field not being annotated when the query resolves.
Author
Owner

@jeremystretch commented on GitHub (May 11, 2022):

This isn't a bug. The member_count field is omitted from the serializer because that data is not available when querying the devices list. (Annotating it would require unduly expensive queries.) It is intended for use and present when retrieving virtual chassis directly in either full or brief mode:

GET /api/dcim/virtual-chassis/?brief=True

{
    "count": 4,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "url": "http://netbox:8000/api/dcim/virtual-chassis/1/",
            "display": "r105-torsw",
            "name": "r105-torsw",
            "master": {
                "id": 98,
                "url": "http://netbox:8000/api/dcim/devices/98/",
                "display": "r105-torsw:1 (98)",
                "name": null
            },
            "member_count": 2
        },
...
@jeremystretch commented on GitHub (May 11, 2022): This isn't a bug. The `member_count` field is omitted from the serializer because that data is not available when querying the devices list. (Annotating it would require unduly expensive queries.) It is intended for use and present when retrieving virtual chassis directly in either full or brief mode: ``` GET /api/dcim/virtual-chassis/?brief=True { "count": 4, "next": null, "previous": null, "results": [ { "id": 1, "url": "http://netbox:8000/api/dcim/virtual-chassis/1/", "display": "r105-torsw", "name": "r105-torsw", "master": { "id": 98, "url": "http://netbox:8000/api/dcim/devices/98/", "display": "r105-torsw:1 (98)", "name": null }, "member_count": 2 }, ... ```
Author
Owner

@PaulWestphal commented on GitHub (May 11, 2022):

In that case, the API documentation of /dcim/devices/ should be changed. Because it still states that there should be a member_count field.

@PaulWestphal commented on GitHub (May 11, 2022): In that case, the API documentation of /dcim/devices/ should be changed. Because it still states that there _should_ be a `member_count` field.
Author
Owner

@PaulWestphal commented on GitHub (May 17, 2022):

Should I create another Issue for the wrong API documentation?

@PaulWestphal commented on GitHub (May 17, 2022): Should I create another Issue for the wrong API documentation?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6467