Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Virtus patching causes unintended consequences #113

@cmoylan

Description

@cmoylan

First off, 👍 to #98

I upgraded the tracker_api on a grape API and noticed that boolean params set to false were becoming nil. I set up a small app to demonstrate this - https://github.com/cmoylan/tracker_grape_example

# without tracker_api in the Gemfile
$ curl localhost:9292/test?my_param=false
false%
$ curl localhost:9292/test?my_param=true
true%
$ curl localhost:9292/test?my_param=asdf
my_param is invalid%


# with tracker_api in Gemfile
$ curl localhost:9292/test?my_param=false

$ curl localhost:9292/test?my_param=true
true%
$ curl localhost:9292/test?my_param=asdf
my_param is invalid%

This is happening because grape uses virtus and tracker_api is adding this bit - https://github.com/dashofcode/tracker_api/blob/master/lib/virtus/attribute/nullify_blank.rb#L17. An additional check like && output != false would solve it. Or just use this as more motivation to ditch virtus entirely.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions