Generated invite links with email can't be redeemed

I am posting to the /invites.json API endpoint with the following JSON:

{
    "email": "new.member@example.com",
    "skip_email": true,
    "max_redemptions_allowed": 1,
    "expires_at": << current date + 1 month >>
    "group_names": "example_group"
}

Which creates a valid invite, of which I grab the invite link and provide to the user.

However, when the user attempts to redeem the invite, it is failing at https://github.com/discourse/discourse/blob/master/app/controllers/invites_controller.rb#L225 with the generic invite.error_message error from failing to update the database for whatever reason.

I’ve been trying to trace the code, but I’m not seeing anything obvious sticking out.

This is an example record from the invites table:

  id  |            invite_key            |            email             | invited_by_id | user_id | redeemed_at |         created_at         |         updated_at         | deleted_at | deleted_by_id |       invalidated_at       | moderator | custom_message | emailed_status | max_redemptions_allowed | redemption_count |       expires_at
 1587 | 4b4e........................2307 | example@gmail.com            |             1 |         |             | 2021-04-11 23:51:05.253528 | 2021-04-11 23:51:05.253528 |            |               |                            | f         |                |              0 |                       1 |                0 | 2021-05-11 11:51:05.193

Have you tried doing so from the UI? Does it work? If so what is the different between the request the UI makes and the one you did?

Is there anything in /logs on the site?

There hasn’t been anything in the logs, unfortunately. I haven’t tried from the UI, will look into that.

BTW, is there a post somewhere that describes how to apply a patch/run a fork in production? See my comment here: Beginners Guide to Install Discourse for Development using Docker - #152 by jessicah.

@sam it appears to only affect some users and not others, but I haven’t been able to identify what’s different :-/

I would run a patch that adds additional logging, but per the link in previous message, whilst I can run a dev environment, I can’t get it working in my production instance, so don’t really know how I can debug :frowning:

Not all users are allowed to invite, are you sure the user performing invites via the API has invite permission?

invited_by_id is 1, a.k.a admin, used for all invites.

1 Like

Hi Jessica,

Our invite code has changed enormously since April, curious if you are still seeing any issues here?

cc @dan

2 Likes