fix(datable): ignore non-hash bounds instead of raising - #8
Merged
Conversation
- `filters[value_date]=2026-01-01` from a plain query string reached `bounds[:after]` on a String and raised TypeError, breaking the never-raise contract - drop attributes whose value is not a hash of bounds in Datable.columns, the single path shared by the four date filters
🛡️ Documentation Quality: 100.0% (0.0%)
✅ Documentation quality above threshold. Changed files
|
🛡️ RuboCop: 0 offenses (0)
✅ No RuboCop offenses. |
🛡️ Coverage Report: 100.0% (0.0%)
✅ All changes are tested. Changed files
|
There was a problem hiding this comment.
Pull request overview
This PR hardens the Filterable::Datable date filters so malformed filters shapes (e.g., a scalar/array where a bounds hash is expected) are ignored rather than raising, preserving the gem’s “never-raise” contract when consuming raw query-string params.
Changes:
- Add a single guard in
Filterable::Datable.columnsto drop non-Hash bounds before the four date filters readbounds[:...]. - Extend specs to cover scalar/array malformed bounds for both plain hashes and
ActionController::Parameters, asserting no exception and an unchanged relation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| spec/filterable_spec.rb | Adds regression coverage ensuring malformed date-filter shapes don’t raise and don’t narrow results. |
| lib/filterable/datable.rb | Filters out non-hash bounds in Datable.columns to prevent TypeError from bounds[:key] on scalars/arrays. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📊 Code Quality Report
🔍 1 new reek smell introduced — review below. 🔍 1 new reek smell introduced by this PR
🔍 All 10 reek smells on this PR
📊 Flog complexity breakdown📊 Flay duplication breakdown |
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.
Summary
A declared datable attribute given a scalar or array value — e.g.
?filters[value_date]=2026-01-01straight from a query string — raisedTypeErrorwhen the date filters readbounds[:after]on a String, violating the gem's never-raise contract.Changes
Datable.columnsnow drops attributes whose value is not a hash of bounds, so a malformed shape narrows nothing (single guard shared by the four date filters)ActionController::Parameters, no longer raise and return the untouched relation