Skip to content

Build your personal knowledge base with Trilium Notes

fix(server): saving revision of note with empty title not supported (closes #6103)

Elian Doran256ffe39f2ee
diff --git a/apps/server/src/becca/entities/brevision.spec.ts b/apps/server/src/becca/entities/brevision.spec.ts
new file mode 100644
index 0000000000..176ee66c03
--- /dev/null
+++ b/apps/server/src/becca/entities/brevision.spec.ts
@@ -0,0 +1,22 @@
+import BRevision from "./brevision.js";
+
+describe("Revision", () => {
+ it("handles note with empty title properly", () => {
+ const revision = new BRevision({
+ revisionId: "4omM5OvlLhOw",
+ noteId: "WHMg7iFCRG3Z",
+ type: "text",
+ mime: "text/html",
+ isProtected: false,
+ title: "",
+ blobId: "",
+ dateLastEdited: "2025-06-27 14:10:39.688+0300",
+ dateCreated: "2025-06-27 14:10:39.688+0300",
+ utcDateLastEdited: "2025-06-27 14:10:39.688+0300",
+ utcDateCreated: "2025-06-27 14:10:39.688+0300",
+ utcDateModified: "2025-06-27 14:10:39.688+0300"
+ });
+ const pojo = revision.getPojo();
+ expect(pojo.title).toBeDefined();
+ });
+});
diff --git a/apps/server/src/becca/entities/brevision.ts b/apps/server/src/becca/entities/brevision.ts
index dcd3103f26..83767a3b2b 100644
--- a/apps/server/src/becca/entities/brevision.ts
+++ b/apps/server/src/becca/entities/brevision.ts
@@ -192,7 +192,7 @@ class BRevision extends AbstractBeccaEntity<BRevision> {
type: this.type,
mime: this.mime,
isProtected: this.isProtected,
- title: this.title || undefined,
+ title: this.title,
blobId: this.blobId,
dateLastEdited: this.dateLastEdited,
dateCreated: this.dateCreated,
@@ -211,10 +211,10 @@ class BRevision extends AbstractBeccaEntity<BRevision> {
if (pojo.isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) {
- pojo.title = protectedSessionService.encrypt(this.title) || undefined;
+ pojo.title = protectedSessionService.encrypt(this.title) ?? "";
} else {
// updating protected note outside of protected session means we will keep original ciphertexts
- delete pojo.title;
+ pojo.title = "";
}
}