Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add invalid tagIds to error message

Tim Wilsoned5b7319ecd4
diff --git a/apps/web/lib/api/links.ts b/apps/web/lib/api/links.ts
index 1c04261e41..24f1d7be29 100644
--- a/apps/web/lib/api/links.ts
+++ b/apps/web/lib/api/links.ts
@@ -422,13 +422,22 @@ export async function processLink({
// tag validity checks
if (tagIds.length > 0) {
const tags = await prisma.tag.findMany({
+ select: {
+ id: true,
+ },
where: { projectId: project?.id, id: { in: tagIds } },
});
if (tags.length !== tagIds.length) {
return {
link: payload,
- error: "One or more tagIds are invalid.",
+ error:
+ "Invalid tagIds: " +
+ tagIds
+ .filter(
+ (tagId) => tags.find(({ id }) => tagId === id) === undefined,
+ )
+ .join(", "),
status: 422,
};
}