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

Missing change log entries for updated many-to-many fields as part of deletes #14079

Closed
fabi125 opened this issue Oct 18, 2023 · 4 comments · Fixed by #15166
Closed

Missing change log entries for updated many-to-many fields as part of deletes #14079

fabi125 opened this issue Oct 18, 2023 · 4 comments · Fixed by #15166
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

@fabi125
Copy link
Contributor

fabi125 commented Oct 18, 2023

NetBox version

v3.6.4

Python version

3.8

Steps to Reproduce

  1. Create a couple of device roles and a config context that is assigned to those two roles:
{
    "id": 1,
    "url": "https://demo.netbox.dev/api/extras/config-contexts/1/",
    "display": "Test Context",
    "name": "Test Context",
    "weight": 1000,
    "description": "",
    "is_active": true,
    "regions": [],
    "site_groups": [],
    "sites": [],
    "locations": [],
    "device_types": [],
    "roles": [
        {
            "id": 13,
            "url": "https://demo.netbox.dev/api/dcim/device-roles/13/",
            "display": "Test Role",
            "name": "Test Role",
            "slug": "test-role"
        },
        {
            "id": 14,
            "url": "https://demo.netbox.dev/api/dcim/device-roles/14/",
            "display": "Test Role 2",
            "name": "Test Role 2",
            "slug": "test-role-2"
        }
    ],
    "platforms": [],
    "cluster_types": [],
    "cluster_groups": [],
    "clusters": [],
    "tenant_groups": [],
    "tenants": [],
    "tags": [],
    "data_source": null,
    "data_path": "",
    "data_file": null,
    "data_synced": null,
    "data": {
        "foo": 123
    },
    "created": "2023-10-18T22:07:46.872083Z",
    "last_updated": "2023-10-18T22:07:46.872120Z"
}
  1. Delete one of the roles

Expected Behavior

This should result in two change log entries: one for the device role deletion and one for the update to the config context.

Observed Behavior

Only a single change log entry is created:

GET /api/extras/object-changes/?request_id=8f69edb2-918f-40da-ac13-2fd1b8d5a3e6

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 5179,
            "url": "https://demo.netbox.dev/api/extras/object-changes/5179/",
            "display": "dcim | device role Test Role deleted by admin",
            "time": "2023-10-18T22:08:46.787241Z",
            "user": {
                "id": 54,
                "url": "https://demo.netbox.dev/api/users/users/54/",
                "display": "admin",
                "username": "admin"
            },
            "user_name": "admin",
            "request_id": "8f69edb2-918f-40da-ac13-2fd1b8d5a3e6",
            "action": {
                "value": "delete",
                "label": "Deleted"
            },
            "changed_object_type": "dcim.devicerole",
            "changed_object_id": 13,
            "changed_object": null,
            "prechange_data": {
                "name": "Test Role",
                "slug": "test-role",
                "tags": [],
                "color": "9e9e9e",
                "created": "2023-10-18T22:07:13.945Z",
                "vm_role": true,
                "description": "",
                "last_updated": "2023-10-18T22:07:13.945Z",
                "custom_fields": {},
                "config_template": null
            },
            "postchange_data": null
        }
    ]
}

But the config context is updated:

{
    "id": 1,
    "url": "https://demo.netbox.dev/api/extras/config-contexts/1/",
    "display": "Test Context",
    "name": "Test Context",
    "weight": 1000,
    "description": "",
    "is_active": true,
    "regions": [],
    "site_groups": [],
    "sites": [],
    "locations": [],
    "device_types": [],
    "roles": [
        {
            "id": 14,
            "url": "https://demo.netbox.dev/api/dcim/device-roles/14/",
            "display": "Test Role 2",
            "name": "Test Role 2",
            "slug": "test-role-2"
        }
    ],
    "platforms": [],
    "cluster_types": [],
    "cluster_groups": [],
    "clusters": [],
    "tenant_groups": [],
    "tenants": [],
    "tags": [],
    "data_source": null,
    "data_path": "",
    "data_file": null,
    "data_synced": null,
    "data": {
        "foo": 123
    },
    "created": "2023-10-18T22:07:46.872083Z",
    "last_updated": "2023-10-18T22:07:46.872120Z"
}

Note: I believe this affects all models that use ManyToManyField relations.

@fabi125 fabi125 added the type: bug A confirmed report of unexpected behavior in the application label Oct 18, 2023
@abhi1693 abhi1693 added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available labels Oct 19, 2023
@jeremystretch
Copy link
Member

I believe this would be addressed by FR #14059.

@fabi125
Copy link
Contributor Author

fabi125 commented Oct 19, 2023

I believe this would be addressed by FR #14059.

Ah yes! I tried to search for open issues, but couldn't find anything. Great timing how you just opened it 2 days ago :)

@abhi1693 abhi1693 added status: blocked Another issue or external requirement is preventing implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Oct 20, 2023
@fabi125
Copy link
Contributor Author

fabi125 commented Oct 20, 2023

Note: I also found this 12 year old Django bug that seems related: https://code.djangoproject.com/ticket/17688
So the easiest way for NetBox to fix this, is probably #14059.

@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows and removed status: blocked Another issue or external requirement is preventing implementation severity: low Does not significantly disrupt application functionality, or a workaround is available labels Dec 27, 2023
@jeremystretch
Copy link
Member

It may be some time before we can tackle #14059 (assuming it's even feasible), so let's see if we can come with a fix in the interim.

@jeremystretch jeremystretch self-assigned this Feb 15, 2024
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Feb 15, 2024
jeremystretch added a commit that referenced this issue Feb 15, 2024
jeremystretch added a commit that referenced this issue Feb 16, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 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
3 participants