Ghost: Cannot read property 'length' of undefined

Created on 26 Oct 2019  路  3Comments  路  Source: TryGhost/Ghost

Issue Summary

Since upgrade to 3.0.0 I see the following error regularly in the system logs:

Oct 26 08:55:11 myhost node[625349]: [2019-10-26 07:55:11] #033[36mINFO#033[39m "GET /modules/ps_banner/img/29357807cb912883def1a6f58174cecc.jpg" #033[36m301#033[39m 2ms
Oct 26 08:55:11 myhost node[625349]: [2019-10-26 07:55:11] #033[31mERROR#033[39m Cannot read property 'length' of undefined
Oct 26 08:55:11 myhost node[625349]: #033[31m
Oct 26 08:55:11 myhost node[625349]: #033[31mCannot read property 'length' of undefined#033[39m
Oct 26 08:55:11 myhost node[625349]: #033[90m----------------------------------------#033[39m
Oct 26 08:55:11 myhost node[625349]: #033[90mTypeError: Cannot read property 'length' of undefined
Oct 26 08:55:11 myhost node[625349]:     at handleCount (/var/www/blog.mydomain/versions/3.0.0/core/frontend/helpers/has.js:21:29)
Oct 26 08:55:11 myhost node[625349]:     at handleAuthor (/var/www/blog.mydomain/versions/3.0.0/core/frontend/helpers/has.js:71:16)
Oct 26 08:55:11 myhost node[625349]:     at Object.author (/var/www/blog.mydomain/versions/3.0.0/core/frontend/helpers/has.js:128:24)
Oct 26 08:55:11 myhost node[625349]:     at /var/www/blog.mydomain/versions/3.0.0/core/frontend/helpers/has.js:157:28
Oct 26 08:55:11 myhost node[625349]:     at /var/www/blog.mydomain/versions/3.0.0/node_modules/lodash/lodash.js:4079:18
Oct 26 08:55:11 myhost node[625349]:     at /var/www/blog.mydomain/versions/3.0.0/node_modules/lodash/lodash.js:4905:15
Oct 26 08:55:11 myhost node[625349]:     at baseForOwn (/var/www/blog.mydomain/versions/3.0.0/node_modules/lodash/lodash.js:2990:24)
Oct 26 08:55:11 myhost node[625349]:     at /var/www/blog.mydomain/versions/3.0.0/node_modules/lodash/lodash.js:4874:18
Oct 26 08:55:11 myhost node[625349]:     at baseSome (/var/www/blog.mydomain/versions/3.0.0/node_modules/lodash/lodash.js:4078:7)
Oct 26 08:55:11 myhost node[625349]:     at Function.some (/var/www/blog.mydomain/versions/3.0.0/node_modules/lodash/lodash.js:9897:14)
Oct 26 08:55:11 myhost node[625349]:     at Object.has (/var/www/blog.mydomain/versions/3.0.0/core/frontend/helpers/has.js:156:16)
Oct 26 08:55:11 myhost node[625349]:     at Object.eval [as main] (eval at createFunctionContext (/var/www/blog.mydomain/versions/3.0.0/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:257:23), <anonymous>:22:68)
Oct 26 08:55:11 myhost node[625349]:     at main (/var/www/blog.mydomain/versions/3.0.0/node_modules/handlebars/dist/cjs/handlebars/runtime.js:175:32)
Oct 26 08:55:11 myhost node[625349]:     at ret (/var/www/blog.mydomain/versions/3.0.0/node_modules/handlebars/dist/cjs/handlebars/runtime.js:178:12)
Oct 26 08:55:11 myhost node[625349]:     at ret (/var/www/blog.mydomain/versions/3.0.0/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:526:21)
Oct 26 08:55:11 myhost node[625349]:     at Object.invokePartial (/var/www/blog.mydomain/versions/3.0.0/node_modules/handlebars/dist/cjs/handlebars/runtime.js:283:12)
Oct 26 08:55:11 myhost node[625349]:     at Object.invokePartialWrapper [as invokePartial] (/var/www/blog.mydomain/versions/3.0.0/node_modules/handlebars/dist/cjs/handlebars/runtime.js:68:39)
Oct 26 08:55:11 myhost node[625349]:     at eval (eval at createFunctionContext (/var/www/blog.mydomain/versions/3.0.0/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:257:23), <anonymous>:6:28)
Oct 26 08:55:11 myhost node[625349]:     at prog (/var/www/blog.mydomain/versions/3.0.0/node_modules/handlebars/dist/cjs/handlebars/runtime.js:221:12)
Oct 26 08:55:11 myhost node[625349]:     at execIteration (/var/www/blog.mydomain/versions/3.0.0/core/frontend/helpers/foreach.js:64:27)
Oct 26 08:55:11 myhost node[625349]:     at _.each (/var/www/blog.mydomain/versions/3.0.0/core/frontend/helpers/foreach.js:83:17)
Oct 26 08:55:11 myhost node[625349]:     at arrayEach (/var/www/blog.mydomain/versions/3.0.0/node_modules/lodash/lodash.js:516:11)#033[39m
Oct 26 08:55:11 myhost node[625349]: #033[39m
Oct 26 08:55:11 myhost node[625349]: [2019-10-26 07:55:11] #033[36mINFO#033[39m "GET /modules/ps_banner/img/29357807cb912883def1a6f58174cecc.jpg/" #033[33m404#033[39m 46ms

To Reproduce

I consider this a bug because it fills system logs, obscuring other issues that need resolving.

Technical details:

  • Ghost Version: 3.0.0
  • Node Version: 10.16.3
  • Browser/OS: unknown - not logged
  • Database: MariaDB 10.1.41 as MySQL 15.1
needs info

Most helpful comment

This has shown up in my logs about a dozen times per day in the last week. I'm using the default Casper 3.0.0 theme, but with disqus added.

In my case this error always follows a 404. I can reproduce the error by hitting a bogus url to generate a 404. The 404 page displays without the post-feed div and the Cannot read property 'length' of undefined error is logged.

All 3 comments

This error being in the logs is definitely not a bug, but the error occurring might be!

It seems to be originating from the has helper - which theme are you using? Maybe there is some incorrect usage of the helper in there or maybe there's a bug in the helper!

This has shown up in my logs about a dozen times per day in the last week. I'm using the default Casper 3.0.0 theme, but with disqus added.

In my case this error always follows a 404. I can reproduce the error by hitting a bogus url to generate a 404. The 404 page displays without the post-feed div and the Cannot read property 'length' of undefined error is logged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HenryMarshall picture HenryMarshall  路  4Comments

albizures picture albizures  路  3Comments

kevinansfield picture kevinansfield  路  3Comments

mattferderer picture mattferderer  路  4Comments

hjzheng picture hjzheng  路  4Comments