Post

Always check user values

A real-life case on why you should never trust the user and always check what they input

Always check user values

Real life case

We had a Ruby on Rails app that synced data from NationBuilder.

We had a NationBuilder form where people submited how many people will attend their event: a people_attending_count field. Suddenly we started getting an ActiveModel::RangeError every time we tried to sync the data from NationBuilder.

It turns out someone input that there would be 7 billion people attending. Keep in mind that the usual value we got was between 5 and 30 people.

Well, we didn’t have a check for that and it broke, because when we save the model with people_attending_count = 7 000 000 000 it broke…

Conclusion

You should always check the user input, but you should also check it as early as possible

This post is licensed under CC BY-NC 4.0 by the author.