Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect GraphQL tooltip when filtering cables by site #365

Closed
matt852 opened this issue Apr 22, 2021 · 1 comment · Fixed by #366
Closed

Incorrect GraphQL tooltip when filtering cables by site #365

matt852 opened this issue Apr 22, 2021 · 1 comment · Fixed by #366
Labels
type: bug Something isn't working as expected

Comments

@matt852
Copy link
Contributor

matt852 commented Apr 22, 2021

Environment

  • Python version: 3.8.5
  • Nautobot version: v1.0.0b5

This bug was introduced with the fix from PR #360. When querying for cables and filtering by site, the tooltip should say something like:

site: [String] [Slug]

However the tooltip actually says

site: [String] [invalid name]

Steps to Reproduce

  1. In the latest develop branch, open GraphQL in the UI
  2. Run a query on cables, like below, and hover over "site"
{
    cables(site: "<site-slug>") {
        id
    }
}

Expected Behavior

The tooltip for "site" should state that the slug is needed

Observed Behavior

The tooltip for "site" shows an "invalid name"
Screen Shot 2021-04-22 at 5 25 08 PM

@jathanism jathanism added the type: bug Something isn't working as expected label Apr 22, 2021
@jathanism
Copy link
Contributor

So we did a little digging and it turns out that for any filterset field that is a method field (such as CableFilterSet.site) a label must also be set, or the text will come back as [invalid name].

Fortunately it appears there aren't a huge amount of them:

$ egrep -r '= .*Filter\(method' nautobot | grep -v label                                      <<<
nautobot/dcim/filters.py:    device_id = MultiValueCharFilter(method="filter_device")
nautobot/dcim/filters.py:    device = MultiValueCharFilter(method="filter_device", field_name="device__name")
nautobot/dcim/filters.py:    rack_id = MultiValueCharFilter(method="filter_device", field_name="device__rack_id")
nautobot/dcim/filters.py:    rack = MultiValueCharFilter(method="filter_device", field_name="device__rack__name")
nautobot/dcim/filters.py:    site_id = MultiValueCharFilter(method="filter_device", field_name="device__site_id")
nautobot/dcim/filters.py:    site = MultiValueCharFilter(method="filter_device", field_name="device__site__slug")
nautobot/dcim/filters.py:    tenant_id = MultiValueCharFilter(method="filter_device", field_name="device__tenant_id")
nautobot/dcim/filters.py:    tenant = MultiValueCharFilter(method="filter_device", field_name="device__tenant__slug")
nautobot/dcim/filters.py:    device_id = MultiValueCharFilter(method="filter_device")
nautobot/dcim/filters.py:    device = MultiValueCharFilter(method="filter_device", field_name="device__name")
nautobot/dcim/filters.py:    device_id = MultiValueCharFilter(method="filter_device")
nautobot/dcim/filters.py:    device = MultiValueCharFilter(method="filter_device", field_name="device__name")
nautobot/dcim/filters.py:    device_id = MultiValueCharFilter(method="filter_device")
nautobot/dcim/filters.py:    device = MultiValueCharFilter(method="filter_device", field_name="device__name")

jathanism added a commit to jathanism/nautobot that referenced this issue Apr 26, 2021
jathanism added a commit that referenced this issue Apr 28, 2021
- Add tests for GraphQL Interface filters
- Also added missing unit tests for `InterfaceFilterSet` in `nautobot.dcim.tests.test_filters`
- Adds/adjusts labels on all filter fields with "method" arguments
- Changes all filter types for "id" fields that were `MultiValueNumberFilter ` to `MultiValueCharFilter `
- Fix #365 - Add/adjust labels on all filter fields with "method" arguments
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants