Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: do not allow invalid reference to be added in relations

Abdullah Atta5bd7a081c1e2
diff --git a/packages/core/src/collections/relations.ts b/packages/core/src/collections/relations.ts
index a5883cabe..b63e3648b 100644
--- a/packages/core/src/collections/relations.ts
+++ b/packages/core/src/collections/relations.ts
@@ -51,6 +51,7 @@ export class Relations implements ICollection {
}
async add(from: ItemReference, to: ItemReference) {
+ if (!from.id || !to.id) throw new Error("Invalid item reference.");
await this.collection.upsert({
id: generateId(from, to),
type: "relation",