Skip to content
Back

users.*.update trigger function - inconsistent request payload

  • 1
  • Self Hosted
  • Accounts
  • Users
  • Functions
anmot.
2 Dec, 2023, 19:43

I am experiencing an issue with the users.*.update trigger function. I've noticed that the payload data provided in the trigger event is inconsistent, particularly when different types of user information are updated.

When an email update occurs, the payload contains the full user object.

TypeScript
 "x-appwrite-event": "users.656ae11125ca984676a9.update",
 {
        "$id": "656ae11125ca984676a9",
        "$createdAt": "2023-12-02T07:47:29.156+00:00",
        "$updatedAt": "2023-12-02T18:52:15.750+00:00",
        "name": "",
        "password": "$argon2id$v=19$m=65536,t=4,p=3$b0NuckhpMHVPRGtOWmFCUA$BG97mP3AIwRfjNS3NoaRqT+vS0e8ITsG8q8MLSY2zGk",
        "hash": "argon2",
        "hashOptions": {
            "type": "argon2",
            "memoryCost": 2048,
            "timeCost": 4,
            "threads": 3
        },
        "registration": "2023-12-02T07:47:29.155+00:00",
        "status": true,
        "labels": [],
        "passwordUpdate": "2023-12-02T07:47:29.155+00:00",
        "email": "admin123@test.com",
        "phone": "",
        "emailVerification": false,
        "phoneVerification": false,
        "prefs": {
            "test": "value"
        },
        "accessedAt": "2023-12-02T07:47:29.155+00:00"
    }
...

Conversely, when a user preference is updated, the payload only contains the preference object, not the full user object.

TypeScript
"x-appwrite-event": "users.656ae11125ca984676a9.update",
{
    "body": {
        "test": "value",
        "test2": "val2"
    },
  ...
}
TL;DR
The user is experiencing an issue with the users.*.update trigger function in an app. When an email is updated, the payload contains the full user object. However, when a user preference is updated, the payload only contains the preference object, not the full user object. The user is seeking clarification on why this inconsistency exists. Possible solution: The user can submit an issue on GitHub to address this inconsistency and seek clarification from the project maintainers.
Drake
2 Dec, 2023, 21:21

This could be fine...but what's odd is it's different between the users API vs the account API. It would be good to create an issue for this

anmot.
2 Dec, 2023, 21:48

Not sure I follow correctly. There is no account.. event trigger for functions right? Both the above request payloads are for user.*.update event. Based on the docs the request payload should be a User object, can you please elaborate why the inconsistent payload could be fine here?

Drake
2 Dec, 2023, 23:36

In the account API, there's a update preferences as well

Drake
2 Dec, 2023, 23:37

Could be a bug...like I said, create an issue

anmot.
3 Dec, 2023, 00:34

Thanks for the clarification. Submitted an issue. https://github.com/appwrite/appwrite/issues/7234

nick_2432
10 Dec, 2023, 06:04
nick_2432
15 Dec, 2023, 01:16

hey @Drake Is there any problem with this PR?

Drake
15 Dec, 2023, 01:35

I'll have to look again tomorrow

nick_2432
16 Dec, 2023, 01:48

@Drake I am having difficulty understanding what changes I need to make. Could you please provide clarification?

Drake
16 Dec, 2023, 01:58
nick_2432
16 Dec, 2023, 02:12

done

nick_2432
18 Dec, 2023, 12:50

all tests have passed. What should I do next?

nick_2432
25 Dec, 2023, 10:09

@Drake The PR at https://github.com/appwrite/appwrite/pull/7264 is still not merged.

Drake
26 Dec, 2023, 00:07

Yes, please give it some time

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more