Skip to content

Related object links from sites to circuit termination not working #19105

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

Closed
corubba opened this issue Apr 7, 2025 · 3 comments
Closed

Related object links from sites to circuit termination not working #19105

corubba opened this issue Apr 7, 2025 · 3 comments
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@corubba
Copy link
Contributor

corubba commented Apr 7, 2025

Deployment Type

Self-hosted

NetBox Version

v4.2.6 (also reproduced it on main branch)

Python Version

3.12

Steps to Reproduce

All steps are done using the web ui in a webbrowser.

  1. Add a new Region named My Region
  2. Add a new Site named My Site
  3. Add a new Circuit Provider named My Circuit Provider
  4. Add a new Circuit Type named My Circuit Type
  5. Add a new Circuit with Circuit ID My Circuit; with Provider My Circuit Provider and Circuit Type My Circuit Type
  6. Add a new Circuit Termination for Circuit My Circuit; with Termination side A, Termination Type DCIM > Region and Termination/Region My Region
  7. Add a new Circuit Termination for Circuit My Circuit; with Termination side Z, Termination Type DCIM > Site and Termination/Site My Site
  8. Open the detail page for the Site My Site (url would be something like /dcim/sites/1/)
  9. Open the detail page for the Region My Region (url would be something like /dcim/regions/1/)
  10. In the Related objects panel on the right side, click the Circuit Terminations link

Expected Behavior

Regarding step 8: The Related objects panel on the right side of the Site detail page contains a Circuit Terminations link, like it is for Region/SiteGroup/Location.

Regarding step 10: The Circuit Termination list page is shown, with filter Region: My Region applied, and only showing entries that are terminated at that region (My Circuit Termination side A from the example above, but not My Circuit Termination side Z).

Observed Behavior

Regarding step 8: The Related objects panel on the right side of the Site detail page does not contain a Circuit Terminations link.

Regarding step 10: The Circuit Termination list page is shown, with no filter applied, and showing all entries. This is (to the best of my knowledge) caused by the link on the detail page pointing to /circuits/circuit-terminations/?_region_id=1 (which is the cached property), but should be /circuits/circuit-terminations/?region_id=1 (without the leading underscore). The Circuit Terminations link on the detail page of SiteGroups and Locations also contain that leading underscore, and are not working as well.


I am willing to work on this. I would be grateful for any (rough) pointers where to start looking and/or what automatism is at work here.
@corubba corubba added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Apr 7, 2025
@bctiemann bctiemann added status: accepted This issue has been accepted for implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Apr 8, 2025
@bctiemann
Copy link
Contributor

Thanks @corubba ! You'll find the logic for populating the "Related Objects" table in the detail views in get_extra_context function on the relevant View class:

netbox/netbox/dcim/views.py

Lines 229 to 257 in 2207ea1

@register_model_view(Region)
class RegionView(GetRelatedModelsMixin, generic.ObjectView):
queryset = Region.objects.all()
def get_extra_context(self, request, instance):
regions = instance.get_descendants(include_self=True)
return {
'related_models': self.get_related_models(
request,
regions,
omit=(Cluster, Prefix, WirelessLAN),
extra=(
(Location.objects.restrict(request.user, 'view').filter(site__region__in=regions), 'region_id'),
(Rack.objects.restrict(request.user, 'view').filter(site__region__in=regions), 'region_id'),
(
Circuit.objects.restrict(request.user, 'view').filter(
terminations___region=instance
).distinct(),
'region_id'
),
# Handle these relations manually to avoid erroneous filter name resolution
(Cluster.objects.restrict(request.user, 'view').filter(_region__in=regions), 'region_id'),
(Prefix.objects.restrict(request.user, 'view').filter(_region__in=regions), 'region_id'),
(WirelessLAN.objects.restrict(request.user, 'view').filter(_region__in=regions), 'region_id'),
),
),
}

@renatoalmeidaoliveira
Copy link
Collaborator

Hello @corubba, I'm already dealing with Related Object on #18932, I can double check for Circuit Terminations too.

@bctiemann
Copy link
Contributor

Thanks @renatoalmeidaoliveira -- I'll close this issue as a duplicate, and @corubba you may want to monitor #18932 to make sure the solution addresses your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available 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

3 participants