Exclude "local_context_data" along with "config_context" #10632

Closed
opened 2025-12-29 21:33:55 +01:00 by adam · 4 comments
Owner

Originally created by @akail on GitHub (Jan 8, 2025).

NetBox version

v4.1.6

Feature type

Change to existing functionality

Triage priority

I volunteer to perform this work (if approved)

Proposed functionality

Remove the field local_context_data when exclude='config_context included with the API call.

Since the config_context is also rendered from the local_context_data this will be included as well.

Will require removing local_context_data from DeviceSerializer in:
d04fc11c61/netbox/dcim/api/serializers_/devices.py (L87)

Use case

Depending on the environments, this will reduce load on the API endpoints in the case of large local_context_data.

Database changes

None

External dependencies

None

Originally created by @akail on GitHub (Jan 8, 2025). ### NetBox version v4.1.6 ### Feature type Change to existing functionality ### Triage priority I volunteer to perform this work (if approved) ### Proposed functionality Remove the field `local_context_data` when `exclude='config_context` included with the API call. Since the `config_context` is also rendered from the `local_context_data` this will be included as well. Will require removing `local_context_data` from DeviceSerializer in: https://github.com/netbox-community/netbox/blob/d04fc11c61684b8ebfcace4328087a14458bf747/netbox/dcim/api/serializers_/devices.py#L87 ### Use case Depending on the environments, this will reduce load on the API endpoints in the case of large `local_context_data`. ### Database changes None ### External dependencies None
adam added the type: featurestatus: needs ownerpending closurecomplexity: medium labels 2025-12-29 21:33:55 +01:00
adam closed this issue 2025-12-29 21:33:55 +01:00
Author
Owner

@tyler-8 commented on GitHub (Jan 8, 2025):

Curious if this parameter lasts much longer since NetBox v4.0 introduced Dynamic REST API Fields:

d04fc11c61/docs/release-notes/version-4.0.md (dynamic-rest-api-fields-15087)

Dynamic REST API Fields (https://github.com/netbox-community/netbox/issues/15087)
The REST API now supports specifying which fields to include in the response data. For example, the response to a request for

GET /api/dcim/sites/?fields=name,status,region,tenant
will include only the four specified fields in the representation of each site. Additionally, the underlying database queries effected by such requests have been optimized to omit fields which are not included in the response, resulting in a substantial performance improvement.

@tyler-8 commented on GitHub (Jan 8, 2025): Curious if this parameter lasts much longer since NetBox v4.0 introduced Dynamic REST API Fields: https://github.com/netbox-community/netbox/blob/d04fc11c61684b8ebfcace4328087a14458bf747/docs/release-notes/version-4.0.md#dynamic-rest-api-fields-15087 > Dynamic REST API Fields (https://github.com/netbox-community/netbox/issues/15087) > The REST API now supports specifying which fields to include in the response data. For example, the response to a request for > > GET /api/dcim/sites/?fields=name,status,region,tenant > will include only the four specified fields in the representation of each site. Additionally, the underlying database queries effected by such requests have been optimized to omit fields which are not included in the response, resulting in a substantial performance improvement.
Author
Owner

@jeremystretch commented on GitHub (Feb 20, 2025):

IMO it makes sense to exclude local context data in any query where ConfigContexts are not being collected.

@akail are you still interested in taking this?

@jeremystretch commented on GitHub (Feb 20, 2025): IMO it makes sense to exclude local context data in any query where ConfigContexts are not being collected. @akail are you still interested in taking this?
Author
Owner

@github-actions[bot] commented on GitHub (May 22, 2025):

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 (May 22, 2025): 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/main/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Jun 21, 2025):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Jun 21, 2025): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10632