Fix 500 on open-ended date input in donations#index (5608)#5614
Open
augustocbx wants to merge 1 commit into
Open
Fix 500 on open-ended date input in donations#index (5608)#5614augustocbx wants to merge 1 commit into
augustocbx wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 reportedNoMethodError: undefined method 'to_fs' for nilfromDateRangeHelper#selected_range_described.Root cause:
selected_intervalsplit the raw range on" - "and mapped each part to aDate. An open-ended value such as"August 25, 2025 - "splits to a single element, so the method returned[Date]with anilend date. Thatnilthen propagated toselected_range_described(end_date.to_fs(:short)),selected_range(end_date.end_of_day), andapplication_controller.rb(selected_interval.map { |d| d.to_fs(:long) }), any of which crashes.Fix:
selected_intervalnow 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
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 failuresbundle exec rspec spec/requests/donations_requests_spec.rb spec/helpers/→ 87 examples, 0 failuresbin/lint app/helpers/date_range_helper.rb spec/helpers/date_range_helper_spec.rb→ no offenses