ahmadnassri / node-har-validator

Extremely fast HTTP Archive (HAR) validator using JSON Schema

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Cannot set property 'items' of undefined" - issue building schemas.log.properites?

jackwanders opened this issue · comments

A project I work on has a dependency on the npm request package, which recently added HAR validation support in v2.54.0:

request/request@4396aef

When we ran a fresh dependency installation on our project, we started getting the following error on server startup:

TypeError: Cannot set property 'items' of undefined
    at Object.<anonymous> (/.../node_modules/request/node_modules/har-validator/src/index.js:36:36)

This leads to the following line in your codebase:

https://github.com/ahmadnassri/har-validator/blob/6b5e9d0093bf1a4deac8f003182983d9239ad131/src/index.js#L36

schemas.log.properties.pages.items = schemas.page

It appears that for some reason schemas.log.properties.pages is undefined, causing this line and by extension our server to fall down.

For the time being, we've fixed our dependency on request to v2.53.0, but I thought it was worth alerting you to this. Any thoughts on if this is an issue in your module or request's use of it?

@jackwanders interesting, I never came across this.. I'll debug in both request and here.

in the meantime, request dependency on har-validator should be version fixed to 1.4.0

@jackwanders just downloaded request from source and ran npm test all were successful including har-validator related tests ... can you give me some steps to reproduce? perhaps your server setup up to the point of including/using request?

this is very peculiar (though may end up being an obvious problem) schemas.log.properties is populated from log.json and it seems the previous lines did not error out!

I am having this issue, and only started getting it two days ago, ill see what I can come up with

@raadad thanks, any steps to re-produce (perhaps your package.json) and some of your app.js would be great to help debug!

I had this same problem and after upgrading har-validator to 1.6.1, the problem went away.

@trevan interesting, I don't honestly see how the changes in 1.6.1 address the issue (was just some re-ordering of files) ... but glad it got fixed!

@raadad @jackwanders can you confirm v1.6.1 fixes this for you as well?