member_count in nested virtual chassis should be removed from example model in REST API documentation. #6591

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

Originally created by @PaulWestphal on GitHub (Jun 23, 2022).

Originally assigned to: @amhn on GitHub.

Change Type

Correction

Area

REST API

Proposed Changes

As explained in this issue (https://github.com/netbox-community/netbox/issues/9329), the nested virtual chassis from the /dcim/devices/ endpoint does not return a member_count. However, the swagger-ui documentation clearly shows an example model WITH this field.

Jeremy argued that this field should not exist, so it should be removed from the example model as well.

Originally created by @PaulWestphal on GitHub (Jun 23, 2022). Originally assigned to: @amhn on GitHub. ### Change Type Correction ### Area REST API ### Proposed Changes As explained in this issue (https://github.com/netbox-community/netbox/issues/9329), the nested virtual chassis from the /dcim/devices/ endpoint does not return a member_count. However, the swagger-ui documentation clearly shows an example model WITH this field. Jeremy argued that this field should not exist, so it should be removed from the example model as well.
adam added the status: acceptedtype: documentation labels 2025-12-29 19:42:43 +01:00
adam closed this issue 2025-12-29 19:42:43 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 23, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Aug 23, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@amhn commented on GitHub (Aug 28, 2022):

member_count needs to be removed from NestedVirtualChassisSerializer and the corresponding test.

Happy to provide a PR.

@amhn commented on GitHub (Aug 28, 2022): member_count needs to be removed from NestedVirtualChassisSerializer and the corresponding test. Happy to provide a PR.
Author
Owner

@DanSheps commented on GitHub (Aug 29, 2022):

@amhn I have assigned this to you.

@DanSheps commented on GitHub (Aug 29, 2022): @amhn I have assigned this to you.
Author
Owner

@jeremystretch commented on GitHub (Aug 29, 2022):

member_count needs to be removed from NestedVirtualChassisSerializer

This is not quite correct. The member_count field is valid and necessary under the /api/dcim/virtual-chassis/, and we should not remove it. The issue identified under #9329 is its erroneous inclusion under other endpoints (e.g. /api/dcim/devices/) where the necessary data is not available. Solving for this requires the introduction of a second nested serializer for use in these cases.

However, we can work around this by instead caching the count of members on each VirtualChassis instance per #10197. As this approach avoids any potentially disruptive changes to the REST API while also resolving the root issue, I'm going to close this issue in favor of the caching approach.

@jeremystretch commented on GitHub (Aug 29, 2022): > member_count needs to be removed from NestedVirtualChassisSerializer This is not quite correct. The `member_count` field is valid and necessary under the `/api/dcim/virtual-chassis/`, and we should not remove it. The issue identified under #9329 is its erroneous inclusion under other endpoints (e.g. `/api/dcim/devices/`) where the necessary data is not available. Solving for this requires the introduction of a second nested serializer for use in these cases. However, we can work around this by instead caching the count of members on each VirtualChassis instance per #10197. As this approach avoids any potentially disruptive changes to the REST API while also resolving the root issue, I'm going to close this issue in favor of the caching approach.
Author
Owner

@amhn commented on GitHub (Aug 29, 2022):

@jeremystretch Providing the the member_count is surely the better solution and should be favored.

But as far as I understood what you describe is exactly what I implemented. The Endpoints in /api/dcim/virtual_chassis still provide member_count and it is only removed from the ones under /api/dcim/devices. Those are as far as I can see the only ones using NestedVirtualChassisSerializer.

I don't want to argue with you. Your solution of caching the member_count is surely the better solution for users of the API. Just want to learn what I misunderstood.

@amhn commented on GitHub (Aug 29, 2022): @jeremystretch Providing the the member_count is surely the better solution and should be favored. But as far as I understood what you describe is exactly what I implemented. The Endpoints in /api/dcim/virtual_chassis still provide member_count and it is *only* removed from the ones under /api/dcim/devices. Those are as far as I can see the only ones using *Nested*VirtualChassisSerializer. I don't want to argue with you. Your solution of caching the member_count is surely the better solution for users of the API. Just want to learn what I misunderstood.
Author
Owner

@jeremystretch commented on GitHub (Aug 29, 2022):

Those are as far as I can see the only ones using NestedVirtualChassisSerializer.

As with all objects, the nested serializer is also used when using "brief" mode for the model endpoint (i.e. /api/dcim/virtual-chassis/?brief=true), so the field needs to stay.

@jeremystretch commented on GitHub (Aug 29, 2022): > Those are as far as I can see the only ones using NestedVirtualChassisSerializer. As with all objects, the nested serializer is also used when using "brief" mode for the model endpoint (i.e. `/api/dcim/virtual-chassis/?brief=true`), so the field needs to stay.
Author
Owner

@amhn commented on GitHub (Aug 29, 2022):

Thank you for the clarification. That is what I suspected, but could not verify. Turns out I was using the wrong netbox instance.

@amhn commented on GitHub (Aug 29, 2022): Thank you for the clarification. That is what I suspected, but could not verify. Turns out I was using the wrong netbox instance.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6591