Fix: blank filter values no longer activate their filter (1.2.1) - #92
Merged
Conversation
1.2.0 activated a filter whenever its param key was present, so an empty value (nil/""/[]) produced conditions like `WHERE col = ''` — a 500 on integer/uuid columns and unintended narrowing elsewhere. Skip blank values again while still honoring a literal `false` (preserves #58). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jakesanders
approved these changes
Aug 4, 2026
HodaSalim
approved these changes
Aug 10, 2026
bunnrf
marked this pull request as ready for review
August 10, 2026 15:55
andrew-wheeler
approved these changes
Aug 10, 2026
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.
Why
1.2.0changedFiltrator#active_filtersso a filter activates whenever its param key is present, regardless of the value. This means a blank value (nil,"",[]) now activates the filter — which the pre-1.2 code deliberately skipped.In practice that turns an empty filter into a real SQL predicate:
WHERE col = ''— harmless on some string columns, but a 500 (PG::InvalidTextRepresentation) on integer / uuid columns.WHERE col IN ()— unintended narrowing to zero rows.NoMethodError.Blank filter values are extremely common (a UI sends
filters[status]=for an unselected dropdown), so consumers on1.2.0see production errors on ordinary requests.What
Restore the pre-1.2 rule that a blank value leaves its filter inactive, while keeping the
1.2.0fix that a literal booleanfalseis a meaningful, active value (#58).active_filtersnow activates a filter only when:so
falsestill filters, butnil/""/[]no longer do.Testing
"",nil,[]) leave the filter inactive and return the full collection. This fails on1.2.0and passes here.Bumps the version to
1.2.1and adds a CHANGELOG entry.