Skip to content

strict_filter mechanism does not respect custom fields in filter #701

@sepetuks

Description

@sepetuks

pynetbox version

7.5.0

NetBox version

v4.2.9

Python version

3.12

Steps to Reproduce

If I have a custom field assigned to tenant, named "CRM_ID"
My Netbox API for tenant looks like:

{
    "id": 2,
    "url": "https://{url}/api/tenancy/tenants/2/",
    "display_url": "https://{url}/tenancy/tenants/2/",
    "display": "Customer A",
    "name": "CustomerA",
    "slug": "CustA",
    "group": {
        "id": 1,
        "url": "https://{url}/api/tenancy/tenant-groups/1/",
        "display": "Group1",
        "name": "Group1",
        "slug": "group1",
        "description": "",
        "tenant_count": 0,
        "_depth": 0
    },
    "description": "",
    "comments": "",
    "tags": [],
    "custom_fields": {
        "CRM_ID": "121121",
        "data_source": null
    },
    "created": "2024-12-06T08:00:41.549254+01:00",
    "last_updated": "2025-02-05T14:29:45.253026+01:00",
    "circuit_count": 0,
    "device_count": 0,
    "ipaddress_count": 9,
    "prefix_count": 13,
    "rack_count": 0,
    "site_count": 0,
    "virtualmachine_count": 0,
    "vlan_count": 12,
    "vrf_count": 1,
    "cluster_count": 0
}

Try to filter tenant using custom field CRM_ID using:
netbox.tenancy.tenants.filter()

Expected Behavior

  • Execute successfully with custom_fields_CRM_ID
  • Strict_filter should not complain about not allowed parameter
  • if cf_CRM_ID is the way to go it should not complain about that

Observed Behavior

If I try to run filter query:

  1. tenants=netbox.tenancy.tenants.filter(custom_fields_CRM_ID=121121, strict_filters=True)
    Result:
    pynetbox.core.query.ParameterValidationError: The request parameter validation returned an error: ["'custom_fields_CRM_ID' is not allowed as parameter on path '/api/tenancy/tenants/'."]
  2. tenants=netbox.tenancy.tenants.filter(cf_CRM_ID=121121, strict_filters=True)
    Result:
    pynetbox.core.query.ParameterValidationError: The request parameter validation returned an error: ["'cf_CRM_ID' is not allowed as parameter on path '/api/tenancy/tenants/'."]
  3. tenants=netbox.tenancy.tenants.filter(cf_CRM_ID=crmid, strict_filters=False)
    Result:
    Successfully retrieves needed object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pynetboxseverity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: needs ownerThis issue is tentatively accepted pending a volunteer committed to its implementationtype: bugA confirmed report of unexpected behavior in the application

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions