Generated invite links with email can't be redeemed

AI-generated summary

Generated invite links with email can’t be redeemed: jessicah is experiencing issues with invite links generated via the /invites.json API endpoint. When users attempt to redeem the invite, they encounter a generic invite.error_message error. jessicah has tried tracing the code but hasn’t found an obvious issue.

sam suggested trying the invite process from the UI and checking the site’s logs for errors. jessicah reported no errors in the logs and hasn’t tried the UI method yet.

The issue seems to only affect some users, and jessicah is struggling to debug the issue in their production instance. sam asked if the user performing invites via the API has invite permission, but jessicah confirmed that the admin user (ID 1) is used for all invites.

sam inquired if the issue still persists, given the invite code changes since April, and CC’d @dan for further assistance.

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 discourse/app/controllers/invites_controller.rb at main · discourse/discourse · GitHub 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: 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