Skip to content

GraphQL ConfigContextFilter requires fields in filter #20215

@tyler-8

Description

@tyler-8

Deployment Type

Self-hosted

NetBox Version

v4.3.7

Python Version

3.12

Steps to Reproduce

  1. Create a site with any name (ie: Atlanta)
  2. Create a config context with any data and assign it to the site from step 1.
  3. Make a GraphQL API call with this query:
query contextList {
  config_context_list(filters: {sites:{name:{in_list:["Atlanta"]}}}) {
    name
    data
  }
}

Expected Behavior

The query returns the configuration context matching the site assignments in the filter.

Observed Behavior

The GraphQL API returns the following output:

{
  "data": null,
  "errors": [
    {
      "message": "Field 'ConfigContextFilter.name' of required type 'StrFilterLookup!' was not provided.",
      "locations": [
        {
          "line": 2,
          "column": 32
        }
      ]
    },
    {
      "message": "Field 'ConfigContextFilter.description' of required type 'StrFilterLookup!' was not provided.",
      "locations": [
        {
          "line": 2,
          "column": 32
        }
      ]
    },
    {
      "message": "Field 'ConfigContextFilter.is_active' of required type 'BoolFilterLookup!' was not provided.",
      "locations": [
        {
          "line": 2,
          "column": 32
        }
      ]
    }
  ]
}

The issue stems from extras/graphql/filters.py and the three fields name, is_active, description not having a union operator with None.

name: FilterLookup[str] = strawberry_django.filter_field()
description: FilterLookup[str] = strawberry_django.filter_field()
is_active: FilterLookup[bool] = strawberry_django.filter_field()

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions