Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: validate if tags exists
Marc Seitz99de78618cb0
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/index.ts b/pages/api/teams/[teamId]/datarooms/[id]/index.tsindex c441144b..ae62482c 100644--- a/pages/api/teams/[teamId]/datarooms/[id]/index.ts+++ b/pages/api/teams/[teamId]/datarooms/[id]/index.ts@@ -165,6 +165,22 @@ export default async function handle(// Handle tags if providedif (tags !== undefined) {+ // Validate that all tags exist and belong to the same team+ if (tags.length > 0) {+ const validTags = await tx.tag.findMany({+ where: {+ id: { in: tags },+ teamId: teamId,+ },+ select: { id: true },+ });+ const validTagIds = new Set(validTags.map((t) => t.id));+ const invalidTags = tags.filter((id) => !validTagIds.has(id));+ if (invalidTags.length > 0) {+ throw new Error(`Invalid tag IDs: ${invalidTags.join(", ")}`);+ }+ }+// First, delete all existing tags for this dataroomawait tx.tagItem.deleteMany({where: {