Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix(import): truncate title to max length in import worker

Mohamed Bassem74b174adc59d
diff --git a/apps/workers/workers/importWorker.ts b/apps/workers/workers/importWorker.ts
index e5b5c27e..2f689d2e 100644
--- a/apps/workers/workers/importWorker.ts
+++ b/apps/workers/workers/importWorker.ts
@@ -22,7 +22,10 @@ import {
} from "@karakeep/db/schema";
import { LowPriorityCrawlerQueue, OpenAIQueue } from "@karakeep/shared-server";
import logger, { throttledLogger } from "@karakeep/shared/logger";
-import { BookmarkTypes } from "@karakeep/shared/types/bookmarks";
+import {
+ BookmarkTypes,
+ MAX_BOOKMARK_TITLE_LENGTH,
+} from "@karakeep/shared/types/bookmarks";
import { registry } from "../metrics";
@@ -371,8 +374,12 @@ export class ImportWorker {
typeof caller.bookmarks.createBookmark
>[0];
+ const normalizedTitle = staged.title
+ ?.trim()
+ .substring(0, MAX_BOOKMARK_TITLE_LENGTH);
+
const baseRequest = {
- title: staged.title ?? undefined,
+ title: normalizedTitle || undefined,
note: staged.note ?? undefined,
createdAt: staged.sourceAddedAt ?? undefined,
crawlPriority: "low" as const,