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

Invalid user causes 500 on application submission creation #461

Closed
werebus opened this issue Oct 25, 2022 · 1 comment
Closed

Invalid user causes 500 on application submission creation #461

werebus opened this issue Oct 25, 2022 · 1 comment
Labels

Comments

@werebus
Copy link
Member

werebus commented Oct 25, 2022

Had a user submit an application with the email address of "theirnetid@umass" (without the umass.edu) today which made the user invalid.

Here's the controller action:

def create
create_user if @current_user.blank?
data = ApplicationDataParser.new(params.require(:data)).result
params.require :position_id
record = ApplicationSubmission.create(record_params
.merge(data: data,
user: @current_user,
reviewed: false))
record.email_subscribers applicant: @current_user
create_unavailability(record) if record.position.application_template.unavailability_enabled?
show_message :application_receipt,
default: 'Your application has been submitted. Thank you!'
redirect_to student_dashboard_path
end

  • create_user tries to create a User, but fails silently, and @current_user ends up remaining nil
  • ApplicationSubmission.create fails because it requires a user to be valid
  • create_unavailability ends up calling record.create_unavailability, which raises an exception:
    An ActiveRecord::RecordNotSaved occurred in application_submissions#create:
    
    You cannot call create unless the parent is saved
      app/controllers/application_submissions_controller.rb:107:in `create_unavailability'

So, in the end, the user got a 500 error and no explanation of what they did wrong.

@werebus werebus added the bug label Oct 25, 2022
@werebus
Copy link
Member Author

werebus commented Jan 9, 2023

Duplicate of #338

@werebus werebus marked this as a duplicate of #338 Jan 9, 2023
@werebus werebus closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant