When referencing an object that does not exist (e.g. $input.path("$").item2), API Gateway will render it as an empty string. However the default behavior of velocityjs is to print out the reference (e.g. "$input.path("$").item2" instead of "").
Using the velocityjs "silence" option will implement the expected behavior.
A potential solution is presented in PR #4