Skip to content

Attempt to address volunteer#create invalid email error in bot-bugsag#6224

Merged
FireLemons merged 13 commits intorubyforgood:mainfrom
rubyforpeace:volunteers#create-bot-bugnsag
Mar 12, 2025
Merged

Attempt to address volunteer#create invalid email error in bot-bugsag#6224
FireLemons merged 13 commits intorubyforgood:mainfrom
rubyforpeace:volunteers#create-bot-bugnsag

Conversation

@7riumph
Copy link
Copy Markdown
Collaborator

@7riumph 7riumph commented Feb 13, 2025

What github issue is this PR for, if any?

Resolves #NaN

Noticed an error with volunteers#create through the discord.

Likely due to an invalid or non standard email.

I refactored it to ensure in the volunteers_controller create function....

  • Invitations to Invalid emails throw an alert

@github-actions github-actions bot added the ruby Pull requests that update Ruby code label Feb 13, 2025
Copy link
Copy Markdown
Collaborator

@compwron compwron left a comment

Choose a reason for hiding this comment

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

Needs specs but a good start!

@FireLemons
Copy link
Copy Markdown
Collaborator

FireLemons commented Feb 19, 2025

The regex addition didn't solve the real life error case of an email address with a close parentheses at the end xxx@gmail.com) and I think it's because it's technically a correct email format according to the RFC URI::MailTo::EMAIL_PATTERN is based off of so instead I think it's better to error handle email send attempts.

for volunteers_controller.rb:35

    if @volunteer.save
      @volunteer.invite!(current_user)
      # call short io api here
      invitation_url = Rails.application.routes.url_helpers.accept_user_invitation_url(invitation_token: @volunteer.raw_invitation_token, host: request.base_url)

I suggest wrapping @volunteer.invite!(current_user) in a try catch so not only does it catch emails with invalid formats i.e. xxx@gmail.com)(from bugsnag) but it will also catch domains and email addresses that don't exist

@compwron
Copy link
Copy Markdown
Collaborator

how's it going?

@7riumph
Copy link
Copy Markdown
Collaborator Author

7riumph commented Feb 26, 2025

how's it going?

Will get back to it now.

@7riumph 7riumph marked this pull request as ready for review March 5, 2025 01:41
@FireLemons FireLemons merged commit 3d88c84 into rubyforgood:main Mar 12, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants