Skip to content

fix: Filter out empty params in QueryReducer#3108

Merged
jlucytan merged 3 commits intomainfrom
jlt/fix/filter-out-empty-params-in-query-reducer
Apr 14, 2026
Merged

fix: Filter out empty params in QueryReducer#3108
jlucytan merged 3 commits intomainfrom
jlt/fix/filter-out-empty-params-in-query-reducer

Conversation

@jlucytan
Copy link
Copy Markdown
Contributor

Scope

No asana ticket. @thecristen mentioned this in Slack.

https://www.mbta.com/departures/?route_id=Red&&direction_id=0&stop_id=place-sstat prod seems to hang indefinitely when I fail at typing and insert an extra & heheh

See slack thread for more details.

Implementation

QueryReducer fails when the URI param has an undefined value (e.g. mbta.com/?&& and mbta.com/?foo&). This PR filters out cases where the key name is empty and adds basic handling for undefined values (simply passes it through as undefined)

Screenshots

Before - page hangs due to the JS param parsing erroring
image

After - normal display
image

How to test

Visit a schedule finder 2.0 page with various unexpected params:

  • && (empty key, no val) local link
  • &foo& (present key, no val) local link
  • &foo=& (present key, empty val) local link
    • this should not hang even before this PR
  • &=bar& (empty key, present val) local link
    • this should not hang even before this PR, but the QueryReducer now strips this entry from the params
    • it may be good to go to other places where we use params to make sure they haven't been affected

verify that they no longer hang

@jlucytan jlucytan requested a review from a team as a code owner April 13, 2026 21:57
@jlucytan jlucytan requested a review from lvachon1 April 13, 2026 21:57
Copy link
Copy Markdown
Contributor

@lvachon1 lvachon1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great!

Comment thread assets/ts/helpers/query.ts Outdated
@jlucytan jlucytan merged commit 67ac713 into main Apr 14, 2026
17 checks passed
@jlucytan jlucytan deleted the jlt/fix/filter-out-empty-params-in-query-reducer branch April 14, 2026 15:50
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.

2 participants