Postgresql 9.6 Error trying to have a function return a string without first casting it as a string.
This has been fixed in version 10, as seen in the docs, Type Conversions:

SELECT Output Columns
The rules given in the preceding sections will result in assignment of non-unknown data types to all expressions in a SQL query, except for unspecified-type literals that appear as simple output columns of a SELECT command. For example, in
 SELECT 'Hello World';

there is nothing to identify what type the string literal should be taken as. In this situation PostgreSQL will fall back to resolving the literal's type as text.
...
Note
Prior to PostgreSQL 10, this rule did not exist, and unspecified-type literals in a SELECT output list were left as type unknown. That had assorted bad consequences, so it's been changed.


The solutions for you are pretty straight forward:
Either cast the values to text or upgrade to version 10.