I am running into a weird issue with dynamoose... The stack is as below:
TypeError: Cannot read properties of undefined (reading 'attributeTypes')
The errors happens in the following function of Item.js:
static isDynamoObject(object, recursive) {
function isValid(value) {
if (typeof value === "undefined" || value === null) {
return false;
}
const keys = Object.keys(value);
const key = keys[0];
const nestedResult = typeof value[key] === "object" && !(value[key] instanceof Buffer) && !(value[key] instanceof Uint8Array) ? Array.isArray(value[key]) ? value[key].every((value) => Item.isDynamoObject(value, true)) : Item.isDynamoObject(value[key]) : true;
const { Schema } = require("./Schema");
const attributeType = Schema.attributeTypes.findDynamoDBType(key);
return typeof value === "object" && keys.length === 1 && attributeType && (nestedResult || Object.keys(value[key]).length === 0 || attributeType.isSet);
}
const keys = Object.keys(object);
const values = Object.values(object);
if (keys.length === 0) {
return null;
}
else {
return recursive ? isValid(object) : values.every((value) => isValid(value));
}
}
it returns the following as undefined:
const { Schema } = require("./Schema");
It works for one model but not for other. I am new to TypeScript and Dynamoose but pretty clueless about why it would fail to load this module only in certain situations.
Expecting Schema to be loaded... I wrote an integration test and within the same integration test, it works fine when I query one model by Id, but fails when I try to do the same for other model.