Wrong data type for some GraphQL fields #11103

Closed
opened 2025-12-29 21:40:21 +01:00 by adam · 1 comment
Owner

Originally created by @corubba on GitHub (Apr 29, 2025).

Originally assigned to: @corubba on GitHub.

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.

Originally created by @corubba on GitHub (Apr 29, 2025). Originally assigned to: @corubba on GitHub. ### 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`. <hr> I traced this back to the GraphQL-Engine-Change in v4.0.0, specifically [45c99e44](https://github.com/netbox-community/netbox/commit/45c99e44779712ea8d24e38262040f4c9cd47637#diff-624cbd4a5e6f6a3b8544506b9e9026958a44d4e021d41655708e73b7d1521d3aR724). 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.
adam added the type: bugstatus: acceptedtopic: GraphQLseverity: low labels 2025-12-29 21:40:21 +01:00
adam closed this issue 2025-12-29 21:40:21 +01:00
Author
Owner

@bctiemann commented on GitHub (May 1, 2025):

Thanks @corubba !

@bctiemann commented on GitHub (May 1, 2025): Thanks @corubba !
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11103