Can't filter by Parent Region in GraphQL #11799

Open
opened 2025-12-29 21:49:59 +01:00 by adam · 0 comments
Owner

Originally created by @tyler-8 on GitHub (Oct 30, 2025).

NetBox Edition

NetBox Community

NetBox Version

v4.4.5

Python Version

3.12

Steps to Reproduce

  1. Create a Tenant "Acme"
  2. Create a region "Canada"
  3. Create a region "Canada East" with "Canada" as its parent
  4. Create a site "HQ" with "Canada East" as its region, and "Acme" as the Tenant.
  5. Create a circuit (of any type, provider), with "Acme" as the Tenant.
  6. Create a circuit termination for the circuit that terminates at "HQ" site.
  7. Attempt the following GraphQL queries:

On circuit_list:

query circuits {
  circuit_list(
    filters: {status: ACTIVE, terminations: {site: {tenant: {name: {exact: "HQ"}}, region: {name: {exact: "Canada"}}}}}
  ) {
    cid
    provider {
      name
    }
    status
    terminations {
      termination {
        ... on SiteType {
          name
          region {
            name
          }
        }
      }
    }
  }
}

On site_list:

query siteList($siteFilters: SiteFilter) {
  site_list(filters: $siteFilters) {
    name
    description
    circuit_terminations {
      circuit {
        cid
        status
        provider {
          name
        }
        tags {
          name
        }
      }
    }
  }
}

JSON variables for second query:

{
  "siteFilters": {
    "status": "STATUS_ACTIVE",
    "tenant": {
      "name": {
        "exact": "Acme"
      }
    },
    "region": {
      "name": {
        "exact": "Canada"
      }
    }
  }
}

Expected Behavior

I would expect to see sites in the site list and circuits in the circuit list that match the target query.

Observed Behavior

An empty result set is returned in both cases. In the GUI and REST API, filtering by parent region returns results. The parent relationship is currently only tracked in RegionFilter with parent_id with no way to include the name (or other attributes) of the parent and requires a separate query to retrieve parent information first. Under the old filter syntax using the direct or parent region attributes worked to filter the query data. With Regions allowing for any number of nesting levels, it's cumbersome to write a query that captures the correct nesting-level for the target parent Region.

Originally created by @tyler-8 on GitHub (Oct 30, 2025). ### NetBox Edition NetBox Community ### NetBox Version v4.4.5 ### Python Version 3.12 ### Steps to Reproduce 1. Create a Tenant "Acme" 2. Create a region "Canada" 3. Create a region "Canada East" with "Canada" as its parent 4. Create a site "HQ" with "Canada East" as its region, and "Acme" as the Tenant. 5. Create a circuit (of any type, provider), with "Acme" as the Tenant. 6. Create a circuit termination for the circuit that terminates at "HQ" site. 7. Attempt the following GraphQL queries: On circuit_list: ```graphql query circuits { circuit_list( filters: {status: ACTIVE, terminations: {site: {tenant: {name: {exact: "HQ"}}, region: {name: {exact: "Canada"}}}}} ) { cid provider { name } status terminations { termination { ... on SiteType { name region { name } } } } } } ``` On site_list: ```graphl query siteList($siteFilters: SiteFilter) { site_list(filters: $siteFilters) { name description circuit_terminations { circuit { cid status provider { name } tags { name } } } } } ``` JSON variables for second query: ```json { "siteFilters": { "status": "STATUS_ACTIVE", "tenant": { "name": { "exact": "Acme" } }, "region": { "name": { "exact": "Canada" } } } } ``` ### Expected Behavior I would expect to see sites in the site list and circuits in the circuit list that match the target query. ### Observed Behavior An empty result set is returned in both cases. In the GUI and REST API, filtering by parent region returns results. The parent relationship is currently only tracked in `RegionFilter` with `parent_id` with no way to include the name (or other attributes) of the parent and requires a separate query to retrieve parent information first. Under the old filter syntax using the direct or parent region attributes worked to filter the query data. With Regions allowing for any number of nesting levels, it's cumbersome to write a query that captures the correct nesting-level for the target parent Region.
adam added the type: bugstatus: needs ownernetboxseverity: low labels 2025-12-29 21:49:59 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11799