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.

guard against performance bounties having null or 0 rewardAmount

Steven Teye2beca7b800c
diff --git a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts b/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
index 7ea885ef9c..60d78b1308 100644
--- a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
@@ -65,10 +65,12 @@ export const PATCH = withWorkspace(
if (startsAt && endsAt && endsAt < startsAt) {
throw new DubApiError({
- message: "endsAt must be on or after startsAt.",
+ message:
+ "Bounty end date (endsAt) must be on or after start date (startsAt).",
code: "bad_request",
});
}
+
const bounty = await prisma.bounty.findUniqueOrThrow({
where: {
id: bountyId,
@@ -79,6 +81,13 @@ export const PATCH = withWorkspace(
},
});
+ if (bounty.type === "performance" && !rewardAmount) {
+ throw new DubApiError({
+ code: "bad_request",
+ message: "Reward amount is required for performance bounties",
+ });
+ }
+
// TODO:
// When we do archive, make sure it disables the workflow
diff --git a/apps/web/app/(ee)/api/bounties/route.ts b/apps/web/app/(ee)/api/bounties/route.ts
index 8d4aeb7d6f..9e14384889 100644
--- a/apps/web/app/(ee)/api/bounties/route.ts
+++ b/apps/web/app/(ee)/api/bounties/route.ts
@@ -89,11 +89,19 @@ export const POST = withWorkspace(
if (startsAt && endsAt && endsAt < startsAt) {
throw new DubApiError({
- message: "endsAt must be on or after startsAt.",
+ message:
+ "Bounty end date (endsAt) must be on or after start date (startsAt).",
code: "bad_request",
});
}
+ if (type === "performance" && !rewardAmount) {
+ throw new DubApiError({
+ code: "bad_request",
+ message: "Reward amount is required for performance bounties",
+ });
+ }
+
const partnerGroups = await throwIfInvalidGroupIds({
programId,
groupIds,