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

Give batch uploading users more information when an email address in their batch is invalid #2297

Merged
merged 3 commits into from
Aug 7, 2023

Conversation

mike29736
Copy link
Contributor

https://trello.com/c/HOwVtQLy/184-give-batch-uploading-users-more-information-when-an-email-address-in-their-batch-is-invalid

Until now, one invalid email address in a batch upload (CSV) would raise
an ambiguous error and give the user no information about what went
wrong.

Now, if the batch encounters a validation problem, it returns to the
original form as before but also displays a more helpful error message.

Though, as I've implemented it, the message could be more helpful. But see for yourself:

Screenshot_2023-08-07_09-07-32

@mike29736 mike29736 force-pushed the give-batch-uploading-users-more-information branch from 407f376 to 9b78962 Compare August 7, 2023 08:56
@floehopper floehopper self-requested a review August 7, 2023 11:57
Copy link
Contributor

@floehopper floehopper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is definitely an improvement, but I've added a comment inline suggesting we might be able to make the error message more actionable by including the first invalid email address. What do you think...?

I'm happy to chat about it if that would be easier.

app/controllers/batch_invitations_controller.rb Outdated Show resolved Hide resolved
app/controllers/batch_invitations_controller.rb Outdated Show resolved Hide resolved
The batch invite process creates a User record based on
a BatchInvitationUser.  Until now, the email address that those two
records share wasn't validated until the User record was created.

The validation rules that the User model employs are provided by Devise
(https://github.com/heartcombo/devise/blob/v4.9.2/lib/devise/models/validatable.rb#L31-L33).
Unfortunately Devise doesn't appear to be able to offer these rules in
isolation, only as a package deal along with validation rules for other
columns that aren't applicable here, so I've duplicated the relevant
ones of those email rules in our model class. (Note:
`email_regexp`/`Devise.email_regexp` is set by us in
config/initializers/devise.rb)
The BatchInvitation and its BatchInvitationUsers are still saved, just
in a different order now.
Until now, one invalid email address in a batch upload (CSV) would raise
an ambiguous error and give the user no information about what went
wrong.

Now, if the batch encounters a validation problem, it returns to the
original form as before but also displays a more helpful error message.

This is a small improvement which avoids some of the complexities of
what might be even more helpful error reports (e.g. listing one or all
of the invalid email addresses).
@mike29736 mike29736 force-pushed the give-batch-uploading-users-more-information branch from 9b78962 to 789b799 Compare August 7, 2023 15:23
@floehopper floehopper self-requested a review August 7, 2023 15:41
Copy link
Contributor

@floehopper floehopper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my feedback. This LGTM now 👍

@mike29736 mike29736 merged commit 3b05865 into main Aug 7, 2023
6 checks passed
@mike29736 mike29736 deleted the give-batch-uploading-users-more-information branch August 7, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants