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

Don't pass nil email address to EmailChecker #10041

Merged
merged 1 commit into from
Nov 11, 2024
Merged

Conversation

CatalinVoineag
Copy link
Contributor

@CatalinVoineag CatalinVoineag commented Nov 8, 2024

Context

In production we have over 12k application references with nil email addresses.

The EmailChecker class expects an email and not a nil value. This creates a few exceptions when a candidate inputs a reference.

The form is saved to DB once the candidate adds a name to the reference, if the candidate moves on, the reference is saved in DB, without a email. So this might be a way we got 12k references without an email.

This commit tries to make sure this class doesn't receive a nil parameter.

https://dfe-teacher-services.sentry.io/issues/6047049953/events/ce842c5fdcad4b9d91787920e1098f91/?environment=production&project=1765973&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D&referrer=previous-event&statsPeriod=24h&stream_index=2

Changes proposed in this pull request

Guidance to review

Things to check

  • If the code removes any existing feature flags, a data migration has also been added to delete the entry from the database
  • This code does not rely on migrations in the same Pull Request
  • If this code includes a migration adding or changing columns, it also backfills existing records for consistency
  • If this code adds a column to the DB, decide whether it needs to be in analytics yml file or analytics blocklist
  • API release notes have been updated if necessary
  • If it adds a significant user-facing change, is it documented in the CHANGELOG?
  • Required environment variables have been updated added to the Azure KeyVault
  • Inform data insights team due to database changes
  • Make sure all information from the Trello card is in here
  • Rebased main
  • Cleaned commit history
  • Tested by running locally
  • Add PR link to Trello card

In production we have over 12k application references with nil email
addresses.

The EmailChecker class expects an email and not a nil value. This
creates a few exceptions when a candidate inputs a reference.

This commit tries to make sure this class doesn't receive a nil parameter.
@CatalinVoineag CatalinVoineag self-assigned this Nov 8, 2024
@CatalinVoineag CatalinVoineag requested a review from a team November 8, 2024 15:32
@CatalinVoineag CatalinVoineag marked this pull request as ready for review November 8, 2024 15:32
Copy link
Contributor

@elceebee elceebee left a comment

Choose a reason for hiding this comment

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

This is an interesting problem. I deliberately required the email_address for the EmailChecker, as I assumed there would be so few without email addresses, we would want it to error if the email address wasn't there. I do wonder how we ended up with 12k!

@dcyoung-dev
Copy link
Collaborator

Should there be a validation on the Reference model?

@CatalinVoineag
Copy link
Contributor Author

CatalinVoineag commented Nov 11, 2024

Should there be a validation on the Reference model?

We can't do this. The form saves to DB when a name is added to a reference. That's how you can end up a reference without an email address. You add a name to a reference and you don't continue adding a email. The reference is now in DB without an email address.

@CatalinVoineag CatalinVoineag merged commit acb21a1 into main Nov 11, 2024
46 checks passed
@CatalinVoineag CatalinVoineag deleted the cv/fix-email-checker branch November 11, 2024 10:14
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.

3 participants