Skip to content

Wrong data type for some GraphQL fields #19361

@corubba

Description

@corubba

Deployment Type

Self-hosted

NetBox Version

v4.2.6

Python Version

3.12

Steps to Reproduce

  1. Open the GraphQL page and execute the following query:
{
  console_port_template_list {
    name
  }
  module_type_list {
    consoleporttemplates {
      name
    }   
  }
}

Expected Behavior

I receive a response with a list of all (if any) console-port-templates and module-types and no errors. This is an example from an empty v3.7.8 instance:

{
  "data": {
    "console_port_template_list": [],
    "module_type_list": []
  }
}

Observed Behavior

I receive the following response/error:

{
  "data": null,
  "errors": [
    {   
      "message": "Cannot query field 'name' on type 'ModuleType'.",
      "locations": [
        {
          "line": 7,
          "column": 7
        }
      ]   
    }   
  ]
}

Note that the error line is in the module_type_list query, not console_port_template_list.


I traced this back to the GraphQL-Engine-Change in v4.0.0, specifically 45c99e44. And because "if it happens once, it may happened twice" I wrote a quick script to compare the field types between the old and new engine, and found a few more suspicious looking ones:

Type IKEPolicyType    Field ipsec_profiles       data-type changed from LIST[IPSecProfileType]        to LIST[IPSecProposalType]
Type ManufacturerType Field device_types         data-type changed from LIST[DeviceTypeType]          to LIST[DeviceType]
Type ManufacturerType Field module_types         data-type changed from LIST[ModuleTypeType]          to LIST[ModuleType]
Type ModuleTypeType   Field consoleporttemplates data-type changed from LIST[ConsolePortTemplateType] to LIST[ModuleType]
Type ModuleTypeType   Field instances            data-type changed from LIST[ModuleType]              to LIST[InterfaceType]
Type ModuleTypeType   Field powerporttemplates   data-type changed from LIST[PowerPortTemplateType]   to LIST[PowerOutletTemplateType]

I would be happy to create a PR for this.

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtopic: GraphQLtype: 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