Open honzajavorek opened 5 years ago
It seems like if this line
blew up because dataRealWithExpected
is not an object but undefined
.
for k, v of dataRealWithExpected then do (k, v) =>
console.log(k, v)
translates to
var k, v;
for (k in dataRealWithExpected) {
v = dataRealWithExpected[k];
((k, v) => {
return console.log(k, v);
})(k, v);
}
Where I believe the for ... in
statement might blow up with a similar error if it got to iterate over undefined
(hunch, not verified).
Surprisingly, iterating over undefined
like this doesn't trigger any error:
> const obj = undefined;
> for (k in obj) { console.log(k); }
undefined
Accessing a property throws a different errorr:
> obj['foo']
TypeError: Cannot read property 'foo' of undefined
But I got completely the same error if calling Object.keys()
on undefined
:
> Object.keys(obj)
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
That means the line numbers are probably off and the problem raises in these two lines:
Both lines are a product of @getFromString
:
There is a path in code which can result in the data not being an object:
However, subsequent code doesn't seem to count with that option.
So the issue is that headers are set to undefined
instead of {}
. There are two steps to mitigation of this issue:
Internal validator error
and performing console.error()
convert undefined or null to object
at Function.keys (
Sometimes gavel2html fails to render the diff for some reason. We're able to see this when using gavel2html internally in apiary.io, but we don't know (yet) what's the exact input to trigger this.