Skip to content

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

Merged
dorner merged 2 commits into
rubyforgood:mainfrom
augustocbx:5608-fix-500-on-open-ended-date-in-donations-index
Jul 17, 2026
Merged

Fix 500 on open-ended date input in donations#index (5608)#5614
dorner merged 2 commits into
rubyforgood:mainfrom
augustocbx:5608-fix-500-on-open-ended-date-in-donations-index

Conversation

@augustocbx

Copy link
Copy Markdown
Contributor

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

@dorner

dorner commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Passes tech review. Needs manual QA. @ruestitch @janeewheatley

@dorner

dorner commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

This can't be tested via the UI - removing the second date auto-fills it back as soon as you blur the input. Not sure how this happened in the first place.

Did some regression testing and the filters seem to work fine as is. Going to merge.

@dorner
dorner merged commit 1f89e0d into rubyforgood:main Jul 17, 2026
11 checks passed
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

2 participants