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

Custom Relationship REST API does not honor filter restrictions #1604

Closed
nniehoff opened this issue Apr 4, 2022 · 0 comments · Fixed by #1776
Closed

Custom Relationship REST API does not honor filter restrictions #1604

nniehoff opened this issue Apr 4, 2022 · 0 comments · Fixed by #1776
Assignees
Labels
type: bug Something isn't working as expected

Comments

@nniehoff
Copy link
Contributor

nniehoff commented Apr 4, 2022

Environment

  • Python version: 3.7
  • Nautobot version: 1.2.10 & 1.2.11b1

When specifying a filter in a custom relationship the UI limits the choices on that side of the relationship to match the filter. However, it is possible to use the API to create a relationship-association which violates this filter.

Steps to Reproduce

  1. Create a 2 sites (object types really don't matter) site1 and site2
  2. Create a VM Cluster cluster1
  3. Create a relationship 1-1 relating a virtualization | cluster to a dcim | site using a filter such as:
{
    "name": "site1"
}
  1. Navigate to the cluster in the UI and attempt to relate the cluster to site2, in the UI you should see the choices are limited to site1.
  2. Use the API to POST to /extras/relationship-associations/ something like (replacing the ids with the source_id of cluster1 and the destination id of site2):
{
  "relationship": "0257b6fb-d8a8-42af-9b60-8e00cc06cce6",
  "source_type": "virtualization.cluster",
  "source_id": "3deaaaa3-a859-4295-a586-3bf71db19f00",
  "destination_type": "dcim.site",
  "destination_id": "cf228b2c-ef24-4169-9070-626e9337b992"
}

Expected Behavior

The UI and the API should be consistent. The API should fail to create the relationship-association as this does not match the given filters.

Observed Behavior

The API creates the relationship with site2 which is invalid in the UI.

@glennmatthews glennmatthews changed the title Custom Relationship API does not honor filters Custom Relationship REST API does not honor filter restrictions Apr 4, 2022
@glennmatthews glennmatthews added the type: bug Something isn't working as expected label Apr 4, 2022
@timizuoebideri1 timizuoebideri1 self-assigned this May 13, 2022
bryanculver added a commit that referenced this issue May 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2022
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
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants