Investigate how large integers are handled across all forms
When you do an advanced search for chat logs by ID, any values >= 2^31 (2147483648) will cause an uncaught ActiveModel::RangeError
exception.
The integer itself is not too large for Ruby, the database column is just a 32-bit signed integer (a 4-byte integer
, according to the Postgres documentation), and I would have to change this to a bigint
to store more than 2^31-1 messages.
Some areas, like searching for reports by user ID, will display a user not found message (not a RangeError
) if you insert an absurdly large value.
For this issue, I need to go through and check all forms that handle numerical input for issues handling large numbers, and ensure users see an error message rather than a 500 page. I also need to patch the chat logs controller to handle this edge case.
-
Patch chat logs controller -
Check every form that takes numerical input and test absurdly large values - store this in the ChatLog model so I can easily reference it (and so it can be updated easily if I upgrade it to a bigint
, or just pull check the DB schema for the type and adjust the max value accordingly) -
Put a note in the readme that the current maximum number of messages that can be stored is 2^31-1, and if you want to store more you have to change chat_log index to a bigint
(and to update the value in the ChatLog model for max ID size if I have to hardcode it)