danielgtaylor / aglio

An API Blueprint renderer with theme support that outputs static HTML
4.75k stars 480 forks source link

TypeError: Cannot read property 'content' of undefined` #237

Open amuino opened 8 years ago

amuino commented 8 years ago

We are constantly getting this error when trying to run aglio (we run it as a server, but it also happen when output goes to a file):

$ aglio -i sample.apib.md -s -p 9876
Server started on http://127.0.0.1:9876/
Rendering sample.apib.md
/Users/amuino/.nvm/versions/node/v5.6.0/lib/node_modules/aglio/node_modules/aglio-theme-olio/lib/main.js:387
    ref = api.content || [];
             ^

TypeError: Cannot read property 'content' of undefined
    at decorate (/Users/amuino/.nvm/versions/node/v5.6.0/lib/node_modules/aglio/node_modules/aglio-theme-olio/lib/main.js:387:14)
    at Object.exports.render (/Users/amuino/.nvm/versions/node/v5.6.0/lib/node_modules/aglio/node_modules/aglio-theme-olio/lib/main.js:645:5)
    at /Users/amuino/.nvm/versions/node/v5.6.0/lib/node_modules/aglio/lib/main.js:133:20

I've attached the minimal test case input file (zipped so that Github will allow me): sample.apib.md.zip

The error disappears when any of this happens:

Versions:

$ aglio -v
aglio 2.2.0
olio 1.6.2
$ node -v
v5.6.0
$ npm -v
3.6.0
amuino commented 8 years ago

Might be related to https://github.com/apiaryio/dredd/issues/381

joseph-norman commented 8 years ago

I'm not sure if its related but I had a similar problem to this - It was being thrown when there was a particular syntax error in my API blueprint spec, related to Defining data structures (using a - instead of a + for each attribute).

Worth a shot if this is what you're doing!

njlittle commented 8 years ago

Was having the same issue, after much ado @joseph-norman and I tracked it down to protagonist - upgrading from 1.2.6 to 1.3.0 appears to have resolved it in my case. Worth a try for the OP.

amuino commented 8 years ago

Thanks @njlittle, I also reported the issue on dredd and drafter, where they found it was a protagonist bug, now fixed.

We have modified our blueprint for the time being to workaround the issue, but will try manually updating drafter.