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

Updating a GFK field via API does not return the new value #12328

Closed
amhn opened this issue Apr 23, 2023 · 3 comments · Fixed by #13946
Closed

Updating a GFK field via API does not return the new value #12328

amhn opened this issue Apr 23, 2023 · 3 comments · Fixed by #13946
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@amhn
Copy link
Contributor

amhn commented Apr 23, 2023

NetBox version

v3.4.8

Python version

3.10

Steps to Reproduce

  1. Create IP-Address (do not assign object)
  2. Create Object to assign (e.g. FHRP Group
  3. curl -H "Authorization: Token $NETBOX_TOKEN" -H "Content-type: application/json" $NETBOX_SCHEME://$NETBOX_URL/api/ipam/ip-addresses/1/ -X PATCH --data '{"assigned_object_type": "ipam.fhrpgroup", "assigned_object_id":1}'

Expected Behavior

assigned_object in the response is not null.

Observed Behavior

assigned_object is null:

{
    "id": 1,
    "url": "http://localhost:8000/api/ipam/ip-addresses/1/",
    "display": "127.0.0.1/32",
    "family": {
        "value": 4,
        "label": "IPv4"
    },
    "address": "127.0.0.1/32",
    "vrf": null,
    "tenant": null,
    "status": {
        "value": "active",
        "label": "Active"
    },
    "role": null,
    "assigned_object_type": "ipam.fhrpgroup",
    "assigned_object_id": 1,
    "assigned_object": null,
    "nat_inside": null,
    "nat_outside": [],
    "dns_name": "",
    "description": "",
    "comments": "",
    "tags": [],
    "custom_fields": {},
    "created": "2023-04-23T09:32:24.766755Z",
    "last_updated": "2023-04-23T09:35:09.908879Z"
}

This is only the case if the assigned_object was not assigned before the request. Changing or removing the assigned object gives the correct response.

@amhn amhn added the type: bug A confirmed report of unexpected behavior in the application label Apr 23, 2023
@jeremystretch jeremystretch added the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label May 2, 2023
@arthanson arthanson self-assigned this May 2, 2023
@arthanson arthanson removed the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label May 2, 2023
@arthanson
Copy link
Collaborator

Potentially a bug in DRF / Django? we aren't doing anything special and it should be getting auto-updated, possibly related to using non-default names for the GFK fields as there have been bugs in Django related to that previously. I'll need to test it with a small sample program.

@amhn
Copy link
Contributor Author

amhn commented May 2, 2023

See my previous comment #10221 (comment) to #10221

Instead of only checking if the object exists, the patch in #11550 should have assigned it to the assigned_object field. I think.

The problem seems to be that None is None and not a None of type GFK. Once there is an object assigned to a GFK the auto update works.

@arthanson
Copy link
Collaborator

Thanks for that, checking...

@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label May 5, 2023
@jeremystretch jeremystretch added the severity: medium Results in substantial degraded or broken functionality for specfic workflows label Jun 23, 2023
@arthanson arthanson removed their assignment Aug 28, 2023
@arthanson arthanson added the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Aug 28, 2023
@arthanson arthanson self-assigned this Oct 2, 2023
@arthanson arthanson removed the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Oct 2, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants