Skip to content

Commit 82545bf

Browse files
committed
revert: go back to a literal 25mb body limit for deploy webhooks
1 parent 1c6d333 commit 82545bf

5 files changed

Lines changed: 11 additions & 39 deletions

File tree

‎apps/dokploy/__test__/deploy/github-webhook-handler.test.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,7 @@ vi.mock("@dokploy/server/db", () => ({
6262
},
6363
}));
6464

65-
vi.mock("next/dist/server/api-utils/node/parse-body", () => ({
66-
parseBody: async (req: { body: unknown }) => req.body,
67-
}));
68-
6965
vi.mock("@dokploy/server", () => ({
70-
DEPLOY_WEBHOOK_MAX_BODY_SIZE: 25 * 1024 * 1024,
7166
IS_CLOUD: false,
7267
shouldDeploy: mocks.shouldDeploy,
7368
checkUserRepositoryPermissions: vi.fn(),

‎apps/dokploy/pages/api/deploy/[refreshToken].ts‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import {
22
type Bitbucket,
3-
DEPLOY_WEBHOOK_MAX_BODY_SIZE,
43
getBitbucketHeaders,
54
IS_CLOUD,
65
shouldDeploy,
76
} from "@dokploy/server";
87
import { db } from "@dokploy/server/db";
98
import { eq } from "drizzle-orm";
109
import type { NextApiRequest, NextApiResponse } from "next";
11-
import { parseBody } from "next/dist/server/api-utils/node/parse-body";
1210
import { applications } from "@/server/db/schema";
1311
import type { DeploymentJob } from "@/server/queues/queue-types";
1412
import { myQueue } from "@/server/queues/queueSetup";
@@ -36,19 +34,16 @@ const getPackageVersion = (headers: any, body: any) => {
3634

3735
export const config = {
3836
api: {
39-
bodyParser: false,
37+
bodyParser: {
38+
sizeLimit: "25mb",
39+
},
4040
},
4141
};
4242

4343
export default async function handler(
4444
req: NextApiRequest,
4545
res: NextApiResponse,
4646
) {
47-
if (Number(req.headers["content-length"]) > DEPLOY_WEBHOOK_MAX_BODY_SIZE) {
48-
res.status(413).json({ message: "Payload too large" });
49-
return;
50-
}
51-
req.body = await parseBody(req, DEPLOY_WEBHOOK_MAX_BODY_SIZE);
5247
const { refreshToken } = req.query;
5348
try {
5449
if (req.headers["x-github-event"] === "ping") {

‎apps/dokploy/pages/api/deploy/compose/[refreshToken].ts‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import {
2-
DEPLOY_WEBHOOK_MAX_BODY_SIZE,
3-
IS_CLOUD,
4-
shouldDeploy,
5-
} from "@dokploy/server";
1+
import { IS_CLOUD, shouldDeploy } from "@dokploy/server";
62
import { db } from "@dokploy/server/db";
73
import { eq } from "drizzle-orm";
84
import type { NextApiRequest, NextApiResponse } from "next";
9-
import { parseBody } from "next/dist/server/api-utils/node/parse-body";
105
import { compose } from "@/server/db/schema";
116
import type { DeploymentJob } from "@/server/queues/queue-types";
127
import { myQueue } from "@/server/queues/queueSetup";
@@ -22,19 +17,16 @@ import {
2217

2318
export const config = {
2419
api: {
25-
bodyParser: false,
20+
bodyParser: {
21+
sizeLimit: "25mb",
22+
},
2623
},
2724
};
2825

2926
export default async function handler(
3027
req: NextApiRequest,
3128
res: NextApiResponse,
3229
) {
33-
if (Number(req.headers["content-length"]) > DEPLOY_WEBHOOK_MAX_BODY_SIZE) {
34-
res.status(413).json({ message: "Payload too large" });
35-
return;
36-
}
37-
req.body = await parseBody(req, DEPLOY_WEBHOOK_MAX_BODY_SIZE);
3830
const { refreshToken } = req.query;
3931
try {
4032
if (req.headers["x-github-event"] === "ping") {

‎apps/dokploy/pages/api/deploy/github.ts‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
checkUserRepositoryPermissions,
33
createPreviewDeployment,
44
createSecurityBlockedComment,
5-
DEPLOY_WEBHOOK_MAX_BODY_SIZE,
65
findGithubById,
76
findPreviewDeploymentByApplicationId,
87
findPreviewDeploymentsByPullRequestId,
@@ -14,7 +13,6 @@ import { db } from "@dokploy/server/db";
1413
import { Webhooks } from "@octokit/webhooks";
1514
import { and, eq } from "drizzle-orm";
1615
import type { NextApiRequest, NextApiResponse } from "next";
17-
import { parseBody } from "next/dist/server/api-utils/node/parse-body";
1816
import { applications, compose, github } from "@/server/db/schema";
1917
import type { DeploymentJob } from "@/server/queues/queue-types";
2018
import { myQueue } from "@/server/queues/queueSetup";
@@ -30,19 +28,16 @@ const getGithubRepositoryOwner = (githubBody: any) =>
3028

3129
export const config = {
3230
api: {
33-
bodyParser: false,
31+
bodyParser: {
32+
sizeLimit: "25mb",
33+
},
3434
},
3535
};
3636

3737
export default async function handler(
3838
req: NextApiRequest,
3939
res: NextApiResponse,
4040
) {
41-
if (Number(req.headers["content-length"]) > DEPLOY_WEBHOOK_MAX_BODY_SIZE) {
42-
res.status(413).json({ message: "Payload too large" });
43-
return;
44-
}
45-
req.body = await parseBody(req, DEPLOY_WEBHOOK_MAX_BODY_SIZE);
4641
const signature = req.headers["x-hub-signature-256"];
4742
if (!signature) {
4843
res.status(401).json({ message: "Missing signature header" });

‎packages/server/src/constants/index.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const DOKPLOY_DOCKER_PORT = process.env.DOKPLOY_DOCKER_PORT
1313

1414
export const CLEANUP_CRON_JOB = "50 23 * * *";
1515

16-
// Body size limits for the OpenAPI catch-all route (pages/api/[...trpc].ts) and the deploy webhooks (pages/api/deploy/*).
16+
// Body size limits for the OpenAPI catch-all route (pages/api/[...trpc].ts).
1717
const parseByteSize = (envVar: string, fallback: number): number => {
1818
const raw = process.env[envVar];
1919
if (!raw) return fallback;
@@ -35,11 +35,6 @@ export const OPENAPI_MAX_UPLOAD_SIZE = parseByteSize(
3535
1024 * 1024 * 1024, // 1gb
3636
);
3737

38-
export const DEPLOY_WEBHOOK_MAX_BODY_SIZE = parseByteSize(
39-
"DEPLOY_WEBHOOK_MAX_BODY_SIZE",
40-
25 * 1024 * 1024, // 25mb, GitHub's max webhook payload
41-
);
42-
4338
type DockerSocketCandidate = {
4439
label: string;
4540
path: string;

0 commit comments

Comments
 (0)