rubyforgood / rubyforgood/awbw

Bulk payment: unhandled UnreadableUpload can 500 the public payment form

Open Beginner friendly
#2,254 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug forms
Dominant language
Ruby
Stars
15
Forks
26
Avg merge
12h 42m
Merged PRs (30d)
242

Description

🤖 From Claude:

What

FormSubmission#persist_answer (extracted from EventRegistrationServices::PublicRegistration on maebeale/public-form-endpoint) raises FormSubmission::UnreadableUpload when a file_upload field's value is a forged or stale direct-upload signed id.

EventRegistrationServices::BulkPayment#call rescues only ActiveRecord::RecordInvalid, so the exception escapes.

Impact

Events::BulkPaymentFormSubmissionsController#create is a public, account-free endpoint. A bulk-payment form carrying a file_upload field would 500 instead of re-rendering with a form error. Before the extraction this path stored the raw value as text and could not raise.

Reachability is currently narrow — the bulk-payment new view renders no file input, so a legitimate submission won't produce the value; it takes a crafted POST or a stale signed id. That's why it's filed rather than fixed inline.

Fix

Add the rescue alongside the existing one in app/services/event_registration_services/bulk_payment.rb:

rescue FormSubmission::UnreadableUpload => e
  Result.new(success?: false, form_submission: nil, errors: [ e.message ])

PublicRegistration and PublicFormSubmission both already rescue it — this is the one caller that doesn't.

Test

Request spec on POST /events/:event_id/bulk_payment_form_submissions with a file_upload field and a garbage signed id: expect :unprocessable_content with the error surfaced, not a raised exception.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in app/services/event_registration_services/bulk_payment.rb and inspect the existing rescue in EventRegistrationServices::BulkPayment#call. Exercise POST /events/:event_id/bulk_payment_form_submissions with a file_upload field and garbage signed id, then verify the response is unprocessable content, surfaces the error, and does not raise; use the existing rescues in PublicRegistration and PublicFormSubmission as reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.