Did some more testing with this.
The error is due to PostgreSQL's habit of being extremely picky with data types...
The first parameter is a "smallint", but we don't have a function to explicitly handle a parameter of that type. PostgreSQL can automatically handle conversion from "smallint" to "integer" and from "smallint" to "text". The problem here is that PostgreSQL doesn't know which function to use.
The simple solution is to just add yet another find_in_set function which explicitly handles smallint:
CREATE OR REPLACE FUNCTION FIND_IN_SET(needle smallint, haystack text) RETURNS integer AS '
SELECT i AS result
FROM generate_series(1, array_upper(string_to_array($2,'',''), 1)) AS g(i)
WHERE (string_to_array($2,'',''))[i] = CAST($1 AS text)
That will fix the issue. I'll commit the change in a bit.