Skip to content

Fix 500 on open-ended date input in donations#index (5608)#5614

Open
augustocbx wants to merge 1 commit into
rubyforgood:mainfrom
augustocbx:5608-fix-500-on-open-ended-date-in-donations-index
Open

Fix 500 on open-ended date input in donations#index (5608)#5614
augustocbx wants to merge 1 commit into
rubyforgood:mainfrom
augustocbx:5608-fix-500-on-open-ended-date-in-donations-index

Conversation

@augustocbx

Copy link
Copy Markdown

Resolves #5608

Description

donations#index (and any page using the dashboard date-range picker) raised a 500 when an open-ended date was entered in the picker — e.g. a start date with no end date. Bugsnag reported NoMethodError: undefined method 'to_fs' for nil from DateRangeHelper#selected_range_described.

Root cause: selected_interval split the raw range on " - " and mapped each part to a Date. An open-ended value such as "August 25, 2025 - " splits to a single element, so the method returned [Date] with a nil end date. That nil then propagated to selected_range_described (end_date.to_fs(:short)), selected_range (end_date.end_of_day), and application_controller.rb (selected_interval.map { |d| d.to_fs(:long) }), any of which crashes.

Fix: selected_interval now destructures into start/end and parses both. When the end date is missing (or either date is unparseable) it falls back to the default range and sets the existing "Invalid Date range provided. Reset to default date range" flash notice — the same graceful behavior already used for invalid ranges. This keeps all downstream callers receiving a complete [start, end] pair.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Added a request-helper spec covering the open-ended date range (asserting fallback to the default range plus the flash notice). Existing valid/invalid range specs still pass.

  • bundle exec rspec spec/helpers/date_range_helper_spec.rb → 3 examples, 0 failures
  • bundle exec rspec spec/requests/donations_requests_spec.rb spec/helpers/ → 87 examples, 0 failures
  • bin/lint app/helpers/date_range_helper.rb spec/helpers/date_range_helper_spec.rb → no offenses

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.

Fix 500 on certain date input in donations#index

1 participant