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

Activities. Resource id is missing in the old activities #9712

Open
Tracked by #9683
Salipa-Gurung opened this issue Jul 30, 2024 · 5 comments
Open
Tracked by #9683

Activities. Resource id is missing in the old activities #9712

Salipa-Gurung opened this issue Jul 30, 2024 · 5 comments

Comments

@Salipa-Gurung
Copy link
Contributor

Salipa-Gurung commented Jul 30, 2024

Describe the bug

For activities api: GET /v1beta1/extensions/org.libregraph/activities, resource id is missing for file creation event when activity is checked after deleting the file.

Steps to reproduce

  1. Upload a file and check activity
{
    "value": [
        {
            "id": "28a2a0e4-d17d-437b-933f-51046f273a84",
            "template": {
                "message": "{user} added {resource} to {space}",
                "variables": {
                    "resource": {
                        "id": "27f71740-c352-4a78-aac2-abe581a673a7$3793776a-a355-45c1-9b29-a1d2fc722ca4!160ae583-9e97-4b39-8158-e5df30325af1",
                        "name": "testavatar.png"
                    },
                    "space": {
                        "id": "3793776a-a355-45c1-9b29-a1d2fc722ca4!3793776a-a355-45c1-9b29-a1d2fc722ca4",
                        "name": "Admin"
                    },
                    "user": {
                        "id": "3793776a-a355-45c1-9b29-a1d2fc722ca4",
                        "displayName": "admin"
                    }
                }
            },
            "times": {
                "recordedTime": "2024-07-30T10:30:56.310361965Z"
            }
        }
    ]
}
  1. Delete the file and check the activity
{
    "value": [
        {
            "id": "1307c6db-9243-482f-943d-8999a85fb1ec",
            "template": {
                "message": "{user} deleted {resource} from {space}",
                "variables": {
                    "resource": {
                        "id": "27f71740-c352-4a78-aac2-abe581a673a7$3793776a-a355-45c1-9b29-a1d2fc722ca4!160ae583-9e97-4b39-8158-e5df30325af1",
                        "name": "testavatar.png"
                    },
                    "space": {
                        "id": "27f71740-c352-4a78-aac2-abe581a673a7$3793776a-a355-45c1-9b29-a1d2fc722ca4!3793776a-a355-45c1-9b29-a1d2fc722ca4",
                        "name": "Admin"
                    },
                    "user": {
                        "id": "3793776a-a355-45c1-9b29-a1d2fc722ca4",
                        "displayName": "admin"
                    }
                }
            },
            "times": {
                "recordedTime": "2024-07-30T10:32:44.990043512Z"
            }
        },
        {
            "id": "28a2a0e4-d17d-437b-933f-51046f273a84",
            "template": {
                "message": "{user} added {resource} to {space}",
                "variables": {
                    "resource": {
                        "id": "",
                        "name": "testavatar.png"
                    },
                    "space": {
                        "id": "27f71740-c352-4a78-aac2-abe581a673a7$3793776a-a355-45c1-9b29-a1d2fc722ca4!3793776a-a355-45c1-9b29-a1d2fc722ca4",
                        "name": "Admin"
                    },
                    "user": {
                        "id": "3793776a-a355-45c1-9b29-a1d2fc722ca4",
                        "displayName": "admin"
                    }
                }
            },
            "times": {
                "recordedTime": "2024-07-30T10:30:56.310361965Z"
            }
        }
    ]
}

For the file upload event, we receive an empty string in the resource id that previously contained the id when checking activity after file deletion.

Expected behavior

There should be resource id.

Actual behavior

Resource id is missing.

@Salipa-Gurung Salipa-Gurung changed the title Resource id is missing Activities. Resource id is missing Jul 30, 2024
@saw-jan saw-jan changed the title Activities. Resource id is missing Activities. Resource id is missing in file deletion activity Aug 1, 2024
@saw-jan saw-jan changed the title Activities. Resource id is missing in file deletion activity Activities. Resource id is missing in the added activity after file deletion Aug 1, 2024
@kobergj
Copy link
Collaborator

kobergj commented Aug 6, 2024

This is somewhat expected behaviour. If an item is deleted, the resourceID cannot be retrieved any more (because the item is gone). Hence this field is omitted in the activity.

Note that the Delete activity is a special case because the event already holds the correct ID. But that information is obsolete as the client cannot do anything with the resourceID (as the item was deleted)

@Salipa-Gurung
Copy link
Contributor Author

Salipa-Gurung commented Aug 6, 2024

When a file is created, renamed and followed by moving it inside a folder then only the last activity (ie. moving the file inside a folder) will have a resource id and all other previous activities will have empty resource id. How about this behaviour? Is this behaviour expected or not?
cc: @kobergj

json response
{
    "value": [
        {
            "id": "d9c43535-14a2-40eb-a394-0911928a477c",
            "template": {
                "message": "{user} moved {resource} to {space}",
                "variables": {
                    "resource": {
                        "id": "2b925c95-bc36-4843-8f97-239aa208632b$c04b4b5a-ca00-48e2-bfb0-f1990461cedb!74257106-28d8-4311-9397-05bed6590955",
                        "name": "error.txt"
                    },
                    "space": {
                        "id": "c04b4b5a-ca00-48e2-bfb0-f1990461cedb!c04b4b5a-ca00-48e2-bfb0-f1990461cedb",
                        "name": "Admin"
                    },
                    "user": {
                        "id": "c04b4b5a-ca00-48e2-bfb0-f1990461cedb",
                        "displayName": "admin"
                    }
                }
            },
            "times": {
                "recordedTime": "2024-08-06T10:10:08.04644023Z"
            }
        },
        {
            "id": "c1661be2-b847-4af4-8c81-125159491fec",
            "template": {
                "message": "{user} renamed {oldResource} to {resource}",
                "variables": {
                    "oldResource": {
                        "id": "",
                        "name": "renamedFile.txt"
                    },
                    "resource": {
                        "id": "",
                        "name": "error.txt"
                    },
                    "user": {
                        "id": "c04b4b5a-ca00-48e2-bfb0-f1990461cedb",
                        "displayName": "admin"
                    }
                }
            },
            "times": {
                "recordedTime": "2024-08-06T10:05:49.625296602Z"
            }
        },
        {
            "id": "d83c1e03-e1f2-4d3f-bf58-b29dda0b79a2",
            "template": {
                "message": "{user} added {resource} to {space}",
                "variables": {
                    "resource": {
                        "id": "",
                        "name": "renamedFile.txt"
                    },
                    "space": {
                        "id": "2b925c95-bc36-4843-8f97-239aa208632b$c04b4b5a-ca00-48e2-bfb0-f1990461cedb!c04b4b5a-ca00-48e2-bfb0-f1990461cedb",
                        "name": "Admin"
                    },
                    "user": {
                        "id": "c04b4b5a-ca00-48e2-bfb0-f1990461cedb",
                        "displayName": "admin"
                    }
                }
            },
            "times": {
                "recordedTime": "2024-08-06T10:05:08.139268732Z"
            }
        }
    ]
}

@kobergj
Copy link
Collaborator

kobergj commented Aug 6, 2024

How about this behaviour? Is this behaviour expected or not?

No. The itemid doesn't change when a file is moved. This is a bug imo.

@saw-jan
Copy link
Member

saw-jan commented Aug 6, 2024

only the latest action activity has the value in the resource id:

"resource": {
   "id": "{resource-id}"

@saw-jan saw-jan changed the title Activities. Resource id is missing in the added activity after file deletion Activities. Resource id is missing in the old activities Aug 7, 2024
@kobergj
Copy link
Collaborator

kobergj commented Aug 8, 2024

I double checked. This is because the events do not contain the itemid but only a reference (containing a path).

The fix to this is rather expensive. There are two options:

A) We pass the itemID through the opaque until the events middleware. This brings some challenges. See for example discussion on this PR: cs3org/reva#4767

B) We get rid of the events middleware and emit events at the place they are created in. This will bring code duplication (e.g. posixfs and decomposedfs both need to emit some events).

Both options are rather costly. I wouldn't want to tackle it without a proper plan.

Fix depends on priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants