Accessing an array in the _source from a javascript script

Hi I am using a javascript based script in the config/script folder using the javascript plugin. Than I use an update request with a script based update. There is something strange happening when using a field containing an array. The following code fails with the message:

   "error": "ElasticsearchIllegalArgumentException[failed to execute script]; nested: EcmaError[TypeError: Cannot find function push in object [/logo.png]. (Script23.js#38)]; ",
   "status": 400

This is the script that gets executed:

var logger = org.elasticsearch.common.logging.ESLoggerFactory.getLogger('jsplugin');;
var doc = ctx._source;

if (doc.numPages != null) {"EXISTING DOCUMENT");
} else {"NEW DOCUMENT");


I simplified the script, but the error is in the last line with the push. If it is a new document there is no error, but an existing document gives an error. The simplified request I do is below:

POST /logsbyip/unique/
  "script_file": "upsertlog",
  "lang": "js", 
  "scripted_upsert": true,
  "params": {
    "log": {
      "request": "/logo.png",
  "upsert": {}

There seems to be happening something with the _source document that is provided to me in the script. Does anyone have an idea what I should do to add an item to the array?